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:
parent
42e45a3d5f
commit
3ebc5a88e8
@ -589,25 +589,30 @@ def truncate_text_to_approximate_size(s, max_bytes, options = {})
|
|||||||
out
|
out
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_path_manpages(path, command)
|
def link_src_dst_dirs(src_dir, dst_dir, command)
|
||||||
return unless (path/"man").exist?
|
return unless src_dir.exist?
|
||||||
conflicts = []
|
conflicts = []
|
||||||
(path/"man").find do |src|
|
src_dir.find do |src|
|
||||||
next if src.directory?
|
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
|
next if dst.symlink? && src == dst.resolved_path
|
||||||
if dst.exist?
|
if dst.exist?
|
||||||
conflicts << dst
|
conflicts << dst
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
dst_dir.mkpath
|
||||||
dst.make_relative_symlink(src)
|
dst.make_relative_symlink(src)
|
||||||
end
|
end
|
||||||
unless conflicts.empty?
|
unless conflicts.empty?
|
||||||
onoe <<-EOS.undent
|
onoe <<-EOS.undent
|
||||||
Could not link #{name} manpages to:
|
Could not link:
|
||||||
#{conflicts.join("\n")}
|
#{conflicts.join("\n")}
|
||||||
|
|
||||||
Please delete these files and run `#{command}`.
|
Please delete these files and run `#{command}`.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def link_path_manpages(path, command)
|
||||||
|
link_src_dst_dirs(path/"man", HOMEBREW_PREFIX/"share", command)
|
||||||
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user