diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 68115632d9..2f3fbc32f1 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -82,6 +82,7 @@ class Pathname src = Pathname(src) dst = join(new_basename) dst = yield(src, dst) if block_given? + return unless dst mkpath diff --git a/Library/Homebrew/install_renamed.rb b/Library/Homebrew/install_renamed.rb index d84e8b28a1..5e200244f3 100644 --- a/Library/Homebrew/install_renamed.rb +++ b/Library/Homebrew/install_renamed.rb @@ -2,7 +2,8 @@ module InstallRenamed def install_p(_, new_basename) super do |src, dst| if src.directory? - dst + dst.install(src.children) + next else append_default_if_different(src, dst) end diff --git a/Library/Homebrew/test/test_pathname.rb b/Library/Homebrew/test/test_pathname.rb index d29a2bc1ea..3dba4e64a5 100644 --- a/Library/Homebrew/test/test_pathname.rb +++ b/Library/Homebrew/test/test_pathname.rb @@ -137,6 +137,16 @@ class PathnameTests < Homebrew::TestCase assert_equal "a", File.read(@dst+@src.basename+@file.basename) end + def test_install_renamed_directory_recursive + @dst.extend(InstallRenamed) + (@dst+@dir.basename).mkpath + (@dst+@dir.basename+"another_file").write "a" + @dir.mkpath + (@dir+"another_file").write "b" + @dst.install @dir + assert_equal "b", File.read(@dst+@dir.basename+"another_file.default") + end + def test_cp_path_sub_file @file.write "a" @file.cp_path_sub @src, @dst