aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/commands.rb
diff options
context:
space:
mode:
authorBaptiste Fontaine2016-01-18 00:55:50 +0100
committerBaptiste Fontaine2016-01-20 22:27:13 +0100
commitc1e673e19a0c02eafb6c24a4ce391b53c2fdbfdc (patch)
tree53382007fbb0331272b7341077493615c20d730b /Library/Homebrew/cmd/commands.rb
parentb8547eab2c9ed2b75e767993b9a20d5f100ae08f (diff)
downloadbrew-c1e673e19a0c02eafb6c24a4ce391b53c2fdbfdc.tar.bz2
commands: support .sh commands
Diffstat (limited to 'Library/Homebrew/cmd/commands.rb')
-rw-r--r--Library/Homebrew/cmd/commands.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/commands.rb b/Library/Homebrew/cmd/commands.rb
index 6630e7134..88290a43d 100644
--- a/Library/Homebrew/cmd/commands.rb
+++ b/Library/Homebrew/cmd/commands.rb
@@ -27,18 +27,30 @@ module Homebrew
end
def internal_commands
- (HOMEBREW_LIBRARY_PATH/"cmd").children.select(&:file?).map { |f| f.basename(".rb").to_s }
+ find_internal_commands HOMEBREW_LIBRARY_PATH/"cmd"
end
def internal_development_commands
- (HOMEBREW_LIBRARY_PATH/"dev-cmd").children.select(&:file?).map { |f| f.basename(".rb").to_s }
+ find_internal_commands HOMEBREW_LIBRARY_PATH/"dev-cmd"
end
def external_commands
- paths.flat_map { |p| Dir["#{p}/brew-*"] }.
- select { |f| File.executable?(f) }.
- map { |f| File.basename(f, ".rb")[5..-1] }.
- reject { |f| f =~ /\./ }.
- sort
+ paths.reduce([]) do |cmds, path|
+ Dir["#{path}/brew-*"].each do |file|
+ next unless File.executable?(file)
+ cmd = File.basename(file, ".rb")[5..-1]
+ cmds << cmd unless cmd.include?(".")
+ end
+ cmds
+ end.sort
+ end
+
+ private
+
+ def find_internal_commands(directory)
+ directory.children.reduce([]) do |cmds, f|
+ cmds << f.basename.to_s.sub(/\.(?:rb|sh)$/, "") if f.file?
+ cmds
+ end
end
end