utils: split link_path_manpages method.

Pull more logic into the more generic `link_src_dst_dirs` to be used to
do more linkage.
This commit is contained in:
Mike McQuaid 2016-09-03 18:02:24 +01:00
parent 42e45a3d5f
commit 3ebc5a88e8

View File

@ -589,25 +589,30 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {})
out
end
def link_path_manpages(path, command)
return unless (path/"man").exist?
def link_src_dst_dirs(src_dir, dst_dir, command)
return unless src_dir.exist?
conflicts = []
(path/"man").find do |src|
src_dir.find do |src|
next if src.directory?
dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path)
dst = dst_dir/src.relative_path_from(src_dir.parent)
next if dst.symlink? && src == dst.resolved_path
if dst.exist?
conflicts << dst
next
end
dst_dir.mkpath
dst.make_relative_symlink(src)
end
unless conflicts.empty?
onoe <<-EOS.undent
Could not link #{name} manpages to:
Could not link:
#{conflicts.join("\n")}
Please delete these files and run `#{command}`.
EOS
end
end
def link_path_manpages(path, command)
link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share", command)
end