Merge pull request #3449 from MikeMcQuaid/diagostic-fix-paths

diagnostic: fix paths usage.
This commit is contained in:
Mike McQuaid 2017-11-17 19:50:04 +00:00 committed by GitHub
commit 889fc81906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -434,7 +434,7 @@ module Homebrew
message = "" message = ""
paths(ENV["HOMEBREW_PATH"]).each do |p| paths.each do |p|
case p case p
when "/usr/bin" when "/usr/bin"
unless @seen_prefix_bin unless @seen_prefix_bin
@ -577,7 +577,7 @@ module Homebrew
/Applications/Server.app/Contents/ServerRoot/usr/sbin /Applications/Server.app/Contents/ServerRoot/usr/sbin
].map(&:downcase) ].map(&:downcase)
paths(ENV["HOMEBREW_PATH"]).each do |p| paths.each do |p|
next if whitelist.include?(p.downcase) || !File.directory?(p) next if whitelist.include?(p.downcase) || !File.directory?(p)
realpath = Pathname.new(p).realpath.to_s realpath = Pathname.new(p).realpath.to_s
@ -1045,7 +1045,7 @@ module Homebrew
end end
def check_for_external_cmd_name_conflict def check_for_external_cmd_name_conflict
cmds = paths.flat_map { |p| Dir["#{p}/brew-*"] }.uniq cmds = Tap.cmd_directories.flat_map { |p| Dir["#{p}/brew-*"] }.uniq
cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) } cmds = cmds.select { |cmd| File.file?(cmd) && File.executable?(cmd) }
cmd_map = {} cmd_map = {}
cmds.each do |cmd| cmds.each do |cmd|

View File

@ -194,7 +194,7 @@ describe Homebrew::Diagnostic::Checks do
FileUtils.chmod 0755, cmd FileUtils.chmod 0755, cmd
end end
ENV["PATH"] = [path1, path2, ENV["PATH"]].join File::PATH_SEPARATOR allow(Tap).to receive(:cmd_directories).and_return([path1, path2])
expect(subject.check_for_external_cmd_name_conflict) expect(subject.check_for_external_cmd_name_conflict)
.to match("brew-foo") .to match("brew-foo")

View File

@ -420,8 +420,8 @@ def nostdout
end end
end end
def paths(env_path = ENV["PATH"]) def paths
@paths ||= PATH.new(env_path).collect do |p| @paths ||= PATH.new(ENV["HOMEBREW_PATH"]).collect do |p|
begin begin
File.expand_path(p).chomp("/") File.expand_path(p).chomp("/")
rescue ArgumentError rescue ArgumentError