diff options
| author | Mike McQuaid | 2017-11-05 15:37:57 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2017-11-05 15:37:57 +0000 |
| commit | 7a68b4a3f96c0cc76f94de2cd72b463b40be0343 (patch) | |
| tree | 3a60bab25001d67966c8bf239b2d7a28f72cd1d3 /Library/Homebrew/commands.rb | |
| parent | c3006f0f121b44baa7acb5e2a023dfd96e582e7a (diff) | |
| download | brew-7a68b4a3f96c0cc76f94de2cd72b463b40be0343.tar.bz2 | |
Refactor command handling code
Don’t rely on having external commands always present in the PATH in
order to find them. Instead, provide an accessory method to Tap so
they can be added and used when needed.
While we’re here, do some general refactoring and cleanup of the
command code in these places.
Diffstat (limited to 'Library/Homebrew/commands.rb')
| -rw-r--r-- | Library/Homebrew/commands.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Library/Homebrew/commands.rb b/Library/Homebrew/commands.rb index caf356b43..9f25f2a2e 100644 --- a/Library/Homebrew/commands.rb +++ b/Library/Homebrew/commands.rb @@ -1,13 +1,10 @@ module Commands def self.path(cmd) - if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb" - end + [ + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh", + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh", + HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb", + HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb", + ].find(&:exist?) end end |
