aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2015-03-26 22:22:45 -0400
committerJack Nagel2015-03-26 22:22:45 -0400
commit05850664d6499ff3a49b180281511f1635aec935 (patch)
tree421b059cd2afddf9cfe04c3f7a438e9efde31020
parentb25b022e3de06e21aefa5994f4bd3f8cb9c9417e (diff)
downloadhomebrew-05850664d6499ff3a49b180281511f1635aec935.tar.bz2
Always yield a path from install_p extension
-rw-r--r--Library/Homebrew/extend/pathname.rb22
-rw-r--r--Library/Homebrew/install_renamed.rb9
2 files changed, 12 insertions, 19 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 0c0555f0e..7ab3cad54 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -41,7 +41,6 @@ class Pathname
dst = join(new_basename).to_s
dst = yield(src, dst) if block_given?
- return unless dst
mkpath
@@ -146,22 +145,17 @@ class Pathname
def cp_path_sub pattern, replacement
raise "#{self} does not exist" unless self.exist?
- src = self.to_s
- dst = src.sub(pattern, replacement)
- raise "#{src} is the same file as #{dst}" if src == dst
+ dst = sub(pattern, replacement)
- dst_path = Pathname.new dst
+ raise "#{self} is the same file as #{dst}" if self == dst
- if self.directory?
- dst_path.mkpath
- return
+ if directory?
+ dst.mkpath
+ else
+ dst.dirname.mkpath
+ dst = yield(self, dst) if block_given?
+ FileUtils.cp(self, dst)
end
-
- dst_path.dirname.mkpath
-
- dst = yield(src, dst) if block_given?
-
- FileUtils.cp(src, dst)
end
# extended to support common double extensions
diff --git a/Library/Homebrew/install_renamed.rb b/Library/Homebrew/install_renamed.rb
index f72fe1309..23d88d1ba 100644
--- a/Library/Homebrew/install_renamed.rb
+++ b/Library/Homebrew/install_renamed.rb
@@ -1,12 +1,11 @@
module InstallRenamed
def install_p(_, new_basename)
super do |src, dst|
- if File.directory? src
- Pathname.new(dst).install Dir["#{src}/*"]
- next
+ if File.directory?(src)
+ dst
+ else
+ append_default_if_different(src, dst)
end
-
- append_default_if_different(src, dst)
end
end