brew-doctor: warning the external commands with conflicting names
Closes Homebrew/homebrew#34755. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
775cfd9117
commit
5310d16686
@ -1181,6 +1181,25 @@ end
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_for_external_cmd_name_conflict
|
||||||
|
cmds = paths.map { |p| Dir["#{p}/brew-*"] }.flatten.uniq
|
||||||
|
cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) }
|
||||||
|
cmd_map = {}
|
||||||
|
cmds.each do |cmd|
|
||||||
|
cmd_name = File.basename(cmd, ".rb")
|
||||||
|
cmd_map[cmd_name] ||= []
|
||||||
|
cmd_map[cmd_name] << cmd
|
||||||
|
end
|
||||||
|
cmd_map.reject! { |cmd_name, cmd_paths| cmd_paths.size == 1 }
|
||||||
|
return if cmd_map.empty?
|
||||||
|
s = "You have external commands with conflicting names."
|
||||||
|
cmd_map.each do |cmd_name, cmd_paths|
|
||||||
|
s += "\n\nFound command `#{cmd_name}` in following places:\n"
|
||||||
|
s += cmd_paths.map { |f| " #{f}" }.join("\n")
|
||||||
|
end
|
||||||
|
s
|
||||||
|
end
|
||||||
|
|
||||||
def all
|
def all
|
||||||
methods.map(&:to_s).grep(/^check_/)
|
methods.map(&:to_s).grep(/^check_/)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user