Update debugger to fail without portable ruby

This commit is contained in:
Rylan Polster 2024-08-15 10:14:52 -04:00
parent 3b63a7eff4
commit 0b5130937f
No known key found for this signature in database
3 changed files with 13 additions and 15 deletions

View File

@ -42,12 +42,8 @@ module Commands
end
def self.valid_ruby_cmd?(cmd)
if (valid_internal_cmd?(cmd) || valid_internal_dev_cmd?(cmd) || external_ruby_v2_cmd_path(cmd)) &&
(command = Homebrew::AbstractCommand.command(cmd))
command.ruby_cmd?
else
false
end
(valid_internal_cmd?(cmd) || valid_internal_dev_cmd?(cmd) || external_ruby_v2_cmd_path(cmd)) &&
Homebrew::AbstractCommand.command(cmd)&.ruby_cmd?
end
def self.method_name(cmd)

View File

@ -11,8 +11,8 @@ module Homebrew
To pass flags to the command, use `--` to separate them from the `brew` flags.
For example: `brew debugger -- list --formula`.
EOS
switch "-n", "--nonstop",
description: "Do not stop at the beginning of the script."
switch "-s", "--stop",
description: "Stop at the beginning of the script."
switch "-O", "--open",
description: "Start remote debugging over a Unix socket."
@ -21,12 +21,14 @@ module Homebrew
sig { override.void }
def run
raise UsageError, "Debugger is only supported with portable Ruby!" unless HOMEBREW_USING_PORTABLE_RUBY
unless Commands.valid_ruby_cmd?(args.named.first)
raise UsageError, "`#{args.named.first}` is not a valid Ruby command!"
end
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
nonstop = "1" if args.nonstop?
nonstop = "1" unless args.stop?
debugger_method = if args.open?
"open"
else

View File

@ -14,12 +14,12 @@ class Homebrew::DevCmd::Debugger::Args < Homebrew::CLI::Args
sig { returns(T::Boolean) }
def O?; end
sig { returns(T::Boolean) }
def n?; end
sig { returns(T::Boolean) }
def nonstop?; end
sig { returns(T::Boolean) }
def open?; end
sig { returns(T::Boolean) }
def s?; end
sig { returns(T::Boolean) }
def stop?; end
end