From 7fc241765e3654718235791c32e5638bf7f8e15a Mon Sep 17 00:00:00 2001 From: Marc Savy Date: Tue, 20 Sep 2016 11:50:27 +0100 Subject: [PATCH] Make mkdir wrapper use mkdir_p to create intermediate directories --- Library/Homebrew/extend/fileutils.rb | 2 +- Library/Homebrew/test/test_pathname.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/fileutils.rb b/Library/Homebrew/extend/fileutils.rb index d5bc3e6d70..3a2b324812 100644 --- a/Library/Homebrew/extend/fileutils.rb +++ b/Library/Homebrew/extend/fileutils.rb @@ -88,7 +88,7 @@ module FileUtils # A version of mkdir that also changes to that folder in a block. def mkdir(name, &_block) - old_mkdir(name) + mkdir_p(name) if block_given? chdir name do yield diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb index 0cd2876d02..bc13241a70 100644 --- a/Library/Homebrew/test/test_pathname.rb +++ b/Library/Homebrew/test/test_pathname.rb @@ -257,4 +257,11 @@ class PathnameInstallTests < Homebrew::TestCase @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