Simplify 'brew cask' check

This commit is contained in:
Phoenix Eliot 2022-02-08 12:08:32 -05:00
parent f18cbd2066
commit 9e2c5910c5
2 changed files with 3 additions and 11 deletions

View File

@ -86,10 +86,6 @@ begin
require "commands"
require "settings"
# Print an error message and exit if the command is no longer supported
unsupported_cmd_message = Commands.unsupported_cmd?(cmd)
odie unsupported_cmd_message if unsupported_cmd_message
internal_cmd = Commands.valid_internal_cmd?(cmd) || Commands.valid_internal_dev_cmd?(cmd) if cmd
unless internal_cmd
@ -125,6 +121,9 @@ begin
possible_tap = Tap.fetch(possible_tap.first) if possible_tap
if !possible_tap || possible_tap.installed? || Tap.untapped_official_taps.include?(possible_tap.name)
if cmd == 'cask' # Check for cask explicitly because it's very common in old guides
odie "`brew cask <command>` is no longer supported. Use `brew <command> --cask` instead."
end
odie "Unknown command: #{cmd}"
end

View File

@ -30,13 +30,6 @@ module Commands
"lc" => "livecheck",
"tc" => "typecheck",
}.freeze
HOMEBREW_UNSUPPORTED_COMMAND_MESSAGES = {
"cask" => "`brew cask <command>` is no longer supported. Use `brew <command> --cask` instead.",
}.freeze
def unsupported_cmd?(cmd)
HOMEBREW_UNSUPPORTED_COMMAND_MESSAGES.fetch(cmd, nil)
end
def valid_internal_cmd?(cmd)
require?(HOMEBREW_CMD_PATH/cmd)