brew/Library/Homebrew/install_renamed.rb

43 lines
768 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
# frozen_string_literal: true
2020-08-17 18:42:42 +02:00
# Helper module for installing default files.
#
# @api private
module InstallRenamed
def install_p(_, new_basename)
super do |src, dst|
2015-03-26 22:22:45 -04:00
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
2017-09-24 20:12:58 +01:00
def +(other)
super(other).extend(InstallRenamed)
end
2017-09-24 20:12:58 +01:00
def /(other)
super(other).extend(InstallRenamed)
end
private
2015-03-26 22:22:45 -04:00
def append_default_if_different(src, dst)
if dst.file? && !FileUtils.identical?(src, dst)
Pathname.new("#{dst}.default")
else
dst
end
end
end