diff options
| author | Markus Reiter | 2016-10-18 17:22:08 +0200 |
|---|---|---|
| committer | Markus Reiter | 2016-10-18 17:22:08 +0200 |
| commit | 6e1c132f99166c716c991d687e4017167c2a37d0 (patch) | |
| tree | 001a7e56e82c0afd3fee053be09782774b48ebbf /Library | |
| parent | 8d83516577b04f8d635e2dee1f95308bad527676 (diff) | |
| download | brew-6e1c132f99166c716c991d687e4017167c2a37d0.tar.bz2 | |
Remove Cask’s `which` method.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/cli.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/utils.rb | 28 |
2 files changed, 2 insertions, 30 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/cli.rb b/Library/Homebrew/cask/lib/hbc/cli.rb index ad8c02aab..11f8cc716 100644 --- a/Library/Homebrew/cask/lib/hbc/cli.rb +++ b/Library/Homebrew/cask/lib/hbc/cli.rb @@ -107,7 +107,7 @@ module Hbc if command.respond_to?(:run) # usual case: built-in command verb command.run(*rest) - elsif require? Utils.which("brewcask-#{command}.rb").to_s + elsif require? which("brewcask-#{command}.rb").to_s # external command as Ruby library on PATH, Homebrew-style elsif command.to_s.include?("/") && require?(command.to_s) # external command as Ruby library with literal path, useful @@ -124,7 +124,7 @@ module Hbc # other Ruby libraries must do everything via "require" klass.run(*rest) end - elsif Utils.which "brewcask-#{command}" + elsif which("brewcask-#{command}") # arbitrary external executable on PATH, Homebrew-style exec "brewcask-#{command}", *ARGV[1..-1] elsif Pathname.new(command.to_s).executable? && diff --git a/Library/Homebrew/cask/lib/hbc/utils.rb b/Library/Homebrew/cask/lib/hbc/utils.rb index c2c091698..38fa23463 100644 --- a/Library/Homebrew/cask/lib/hbc/utils.rb +++ b/Library/Homebrew/cask/lib/hbc/utils.rb @@ -38,34 +38,6 @@ end module Hbc module Utils - def self.which(cmd, path = ENV["PATH"]) - unless File.basename(cmd) == cmd.to_s - # cmd contains a directory element - cmd_pn = Pathname(cmd) - return nil unless cmd_pn.absolute? - return resolve_executable(cmd_pn) - end - path.split(File::PATH_SEPARATOR).each do |elt| - fq_cmd = Pathname(elt).expand_path.join(cmd) - resolved = resolve_executable fq_cmd - return resolved if resolved - end - nil - end - - def self.resolve_executable(cmd) - cmd_pn = Pathname(cmd) - return nil unless cmd_pn.exist? - return nil unless cmd_pn.executable? - begin - cmd_pn = Pathname(cmd_pn.realpath) - rescue RuntimeError - return nil - end - return nil unless cmd_pn.file? - cmd_pn - end - def self.gain_permissions_remove(path, command: SystemCommand) if path.respond_to?(:rmtree) && path.exist? gain_permissions(path, ["-R"], command, &:rmtree) |
