diff options
| author | Mike McQuaid | 2016-09-03 18:02:24 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-09-06 09:04:51 +0100 |
| commit | 3ebc5a88e89aa321ef7aa31900873b91d99cfd01 (patch) | |
| tree | f56529eb4807f0c8c809bde90b9eee87fa0f2fe6 /Library | |
| parent | 42e45a3d5f68eb98488297078c67e621d744961f (diff) | |
| download | brew-3ebc5a88e89aa321ef7aa31900873b91d99cfd01.tar.bz2 | |
utils: split link_path_manpages method.
Pull more logic into the more generic `link_src_dst_dirs` to be used to
do more linkage.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/utils.rb | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 41b9a4661..373320f75 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 |
