From 49dcbee99c46d92d65e9132a555ed3fc2865c1e6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 7 Sep 2016 20:09:22 +0100 Subject: [PATCH] command: use Commands module. --- Library/Homebrew/cmd/command.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb index bab0257c83..b76468f621 100644 --- a/Library/Homebrew/cmd/command.rb +++ b/Library/Homebrew/cmd/command.rb @@ -1,13 +1,15 @@ #: * `command` : #: Display the path to the file which is used when invoking `brew` . +require "commands" + module Homebrew def command abort "This command requires a command argument" if ARGV.empty? cmd = ARGV.first cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - if (path = internal_command_path cmd) + if (path = Commands.path(cmd)) puts path elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb")) puts path @@ -15,13 +17,4 @@ 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}" } - paths += extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.#{ext}" } - paths.find { |p| p.file? } - end end