Always yield a path from install_p extension
This commit is contained in:
parent
522f7ea8c7
commit
3721e0be6f
@ -41,7 +41,6 @@ class Pathname
|
|||||||
dst = join(new_basename).to_s
|
dst = join(new_basename).to_s
|
||||||
|
|
||||||
dst = yield(src, dst) if block_given?
|
dst = yield(src, dst) if block_given?
|
||||||
return unless dst
|
|
||||||
|
|
||||||
mkpath
|
mkpath
|
||||||
|
|
||||||
@ -146,22 +145,17 @@ class Pathname
|
|||||||
def cp_path_sub pattern, replacement
|
def cp_path_sub pattern, replacement
|
||||||
raise "#{self} does not exist" unless self.exist?
|
raise "#{self} does not exist" unless self.exist?
|
||||||
|
|
||||||
src = self.to_s
|
dst = sub(pattern, replacement)
|
||||||
dst = src.sub(pattern, replacement)
|
|
||||||
raise "#{src} is the same file as #{dst}" if src == dst
|
|
||||||
|
|
||||||
dst_path = Pathname.new dst
|
raise "#{self} is the same file as #{dst}" if self == dst
|
||||||
|
|
||||||
if self.directory?
|
if directory?
|
||||||
dst_path.mkpath
|
dst.mkpath
|
||||||
return
|
else
|
||||||
|
dst.dirname.mkpath
|
||||||
|
dst = yield(self, dst) if block_given?
|
||||||
|
FileUtils.cp(self, dst)
|
||||||
end
|
end
|
||||||
|
|
||||||
dst_path.dirname.mkpath
|
|
||||||
|
|
||||||
dst = yield(src, dst) if block_given?
|
|
||||||
|
|
||||||
FileUtils.cp(src, dst)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# extended to support common double extensions
|
# extended to support common double extensions
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
module InstallRenamed
|
module InstallRenamed
|
||||||
def install_p(_, new_basename)
|
def install_p(_, new_basename)
|
||||||
super do |src, dst|
|
super do |src, dst|
|
||||||
if File.directory? src
|
if File.directory?(src)
|
||||||
Pathname.new(dst).install Dir["#{src}/*"]
|
dst
|
||||||
next
|
else
|
||||||
end
|
|
||||||
|
|
||||||
append_default_if_different(src, dst)
|
append_default_if_different(src, dst)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cp_path_sub pattern, replacement
|
def cp_path_sub pattern, replacement
|
||||||
super do |src, dst|
|
super do |src, dst|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user