From 3ebc5a88e89aa321ef7aa31900873b91d99cfd01 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 3 Sep 2016 18:02:24 +0100 Subject: [PATCH] utils: split link_path_manpages method. Pull more logic into the more generic `link_src_dst_dirs` to be used to do more linkage. --- Library/Homebrew/utils.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 41b9a46615..373320f757 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -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