Skip to content

Commit

Permalink
Merge pull request #1043 from msavy/mkdir_with_intermediates
Browse files Browse the repository at this point in the history
Alter mkdir wrapper use mkdir_p to create intermediate directories
  • Loading branch information
MikeMcQuaid authored Sep 24, 2016
2 parents 96b1e23 + e767fd3 commit 817bc27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run

# A version of mkdir that also changes to that folder in a block.
def mkdir(name, &_block)
old_mkdir(name)
mkdir_p(name)
return unless block_given?
chdir name do
yield
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/test/test_pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,11 @@ def test_install_relative_symlink
@dst.install_symlink "foo" => "bar"
assert_equal Pathname.new("foo"), (@dst/"bar").readlink
end

def test_mkdir_creates_intermediate_directories
mkdir @dst/"foo/bar/baz" do
assert_predicate @dst/"foo/bar/baz", :exist?, "foo/bar/baz was not created"
assert_predicate @dst/"foo/bar/baz", :directory?, "foo/bar/baz was not a directory structure"
end
end
end

0 comments on commit 817bc27

Please sign in to comment.