Merge pull request #4965 from rolandwalker/doctor_load_path_annotation
Annotatate unexpected $LOAD_PATH in doctor
This commit is contained in:
commit
a0a5ba44df
|
@ -14,7 +14,7 @@ class Cask::CLI::Doctor
|
|||
ohai 'Homebrew-cask Default Tap Path:', render_tap_paths( fq_default_tap )
|
||||
ohai 'Homebrew-cask Alternate Cask Taps:', render_tap_paths( alt_taps )
|
||||
ohai 'Homebrew-cask Default Tap Cask Count:', render_with_none_as_error( default_cask_count )
|
||||
ohai 'Contents of $LOAD_PATH:', render_with_none_as_error( $LOAD_PATH )
|
||||
ohai 'Contents of $LOAD_PATH:', render_load_path( $LOAD_PATH )
|
||||
ohai 'Contents of $RUBYLIB Environment Variable:', render_env_var( 'RUBYLIB' )
|
||||
ohai 'Contents of $RUBYOPT Environment Variable:', render_env_var( 'RUBYOPT' )
|
||||
ohai 'Contents of $RUBYPATH Environment Variable:', render_env_var( 'RUBYPATH' )
|
||||
|
@ -149,6 +149,17 @@ class Cask::CLI::Doctor
|
|||
end
|
||||
end
|
||||
|
||||
def self.render_load_path(paths)
|
||||
if paths.nil? or paths.size == 0
|
||||
return "#{none_string} #{error_string}"
|
||||
end
|
||||
copy = Array.new(paths)
|
||||
unless Cask::Utils.file_is_descendant(copy[0], HOMEBREW_CELLAR)
|
||||
copy[0] = "#{copy[0]} #{error_string %Q{error: should be descendant of HOMEBREW_CELLAR}}"
|
||||
end
|
||||
copy
|
||||
end
|
||||
|
||||
def self.help
|
||||
"checks for configuration issues"
|
||||
end
|
||||
|
|
|
@ -112,4 +112,25 @@ module Cask::Utils
|
|||
stdout.read
|
||||
end
|
||||
end
|
||||
|
||||
# paths that "look" descendant (textually) will still
|
||||
# return false unless both the given paths exist
|
||||
def self.file_is_descendant(file, dir)
|
||||
file = Pathname.new(file)
|
||||
dir = Pathname.new(dir)
|
||||
return false unless file.exist? and dir.exist?
|
||||
unless dir.directory?
|
||||
onoe "Argument must be a directory: '#{dir}'"
|
||||
return false
|
||||
end
|
||||
unless file.absolute? and dir.absolute?
|
||||
onoe "Both arguments must be absolute: '#{file}', '#{dir}'"
|
||||
return false
|
||||
end
|
||||
while file.parent != file
|
||||
return true if File.identical?(file, dir)
|
||||
file = file.parent
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue