diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index 8b8d21da4dd98..4f20d36a3bd9d 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -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 diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb index 492c09c67a610..2f6360719b030 100644 --- a/Library/Homebrew/test/test_pathname.rb +++ b/Library/Homebrew/test/test_pathname.rb @@ -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