diff options
Diffstat (limited to 'Library/Homebrew/extend/pathname.rb')
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 22 |
1 files changed, 8 insertions, 14 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 |
