mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
37 lines
660 B
Ruby
37 lines
660 B
Ruby
module InstallRenamed
|
|
def install_p(_, new_basename)
|
|
super do |src, dst|
|
|
if src.directory?
|
|
dst.install(src.children)
|
|
next
|
|
else
|
|
append_default_if_different(src, dst)
|
|
end
|
|
end
|
|
end
|
|
|
|
def cp_path_sub(pattern, replacement)
|
|
super do |src, dst|
|
|
append_default_if_different(src, dst)
|
|
end
|
|
end
|
|
|
|
def +(other)
|
|
super(other).extend(InstallRenamed)
|
|
end
|
|
|
|
def /(other)
|
|
super(other).extend(InstallRenamed)
|
|
end
|
|
|
|
private
|
|
|
|
def append_default_if_different(src, dst)
|
|
if dst.file? && !FileUtils.identical?(src, dst)
|
|
Pathname.new("#{dst}.default")
|
|
else
|
|
dst
|
|
end
|
|
end
|
|
end
|