aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorBaptiste Fontaine2016-01-18 01:22:35 +0100
committerBaptiste Fontaine2016-01-20 22:27:13 +0100
commit5775d3b326949eba3a83a39b31595e0f56bc9a82 (patch)
treea1f127d3b4a8c6c1d567ff1e6a467e8cb18e66fe /Library/Homebrew/cmd
parentc1e673e19a0c02eafb6c24a4ce391b53c2fdbfdc (diff)
downloadbrew-5775d3b326949eba3a83a39b31595e0f56bc9a82.tar.bz2
command: support .sh commands
Closes Homebrew/homebrew#48192. Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/command.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb
index 4790a6952..ad7f99288 100644
--- a/Library/Homebrew/cmd/command.rb
+++ b/Library/Homebrew/cmd/command.rb
@@ -4,9 +4,7 @@ module Homebrew
cmd = ARGV.first
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
- if (path = HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb").file?
- puts path
- elsif ARGV.homebrew_developer? && (path = HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb").file?
+ if (path = internal_command_path cmd)
puts path
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
puts path
@@ -14,4 +12,17 @@ module Homebrew
odie "Unknown command: #{cmd}"
end
end
+
+ private
+
+ def internal_command_path(cmd)
+ extensions = %w[rb sh]
+ paths = extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.#{ext}" }
+
+ if ARGV.homebrew_developer?
+ paths += extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.#{ext}" }
+ end
+
+ paths.find { |p| p.file? }
+ end
end