dev-cmd/typecheck: Use Sorbet's --dir to set the tap path

- This means we don't have to copy config files around,
  and users get instant results rather than having
  to run `srb init`.
This commit is contained in:
Issy Long 2024-08-13 11:04:15 +01:00
parent 807093f276
commit feedc5c84e
No known key found for this signature in database

View File

@ -44,15 +44,18 @@ module Homebrew
sig { override.void } sig { override.void }
def run def run
if (args.dir.present? || args.file.present?) && args.named.present?
raise UsageError, "Cannot use `--dir` or `--file` when specifying a tap."
end
update = args.update? || args.update_all? update = args.update? || args.update_all?
directory = args.no_named? ? HOMEBREW_LIBRARY_PATH : args.named.to_paths(only: :tap).first
groups = update ? Homebrew.valid_gem_groups : ["typecheck"] groups = update ? Homebrew.valid_gem_groups : ["typecheck"]
Homebrew.install_bundler_gems!(groups:) Homebrew.install_bundler_gems!(groups:)
# Sorbet doesn't use bash privileged mode so we align EUID and UID here. # Sorbet doesn't use bash privileged mode so we align EUID and UID here.
Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid Process::UID.change_privilege(Process.euid) if Process.euid != Process.uid
directory.cd do HOMEBREW_LIBRARY_PATH.cd do
if update if update
workers = args.debug? ? ["--workers=1"] : [] workers = args.debug? ? ["--workers=1"] : []
safe_system "bundle", "exec", "tapioca", "dsl", *workers safe_system "bundle", "exec", "tapioca", "dsl", *workers
@ -96,10 +99,11 @@ module Homebrew
end end
srb_exec += ["--ignore", args.ignore] if args.ignore.present? srb_exec += ["--ignore", args.ignore] if args.ignore.present?
if args.file.present? || args.dir.present? if args.file.present? || args.dir.present? || (tap_dir = args.named.to_paths(only: :tap).first).present?
cd("sorbet") do cd("sorbet") do
srb_exec += ["--file", "../#{args.file}"] if args.file srb_exec += ["--file", "../#{args.file}"] if args.file
srb_exec += ["--dir", "../#{args.dir}"] if args.dir srb_exec += ["--dir", "../#{args.dir}"] if args.dir
srb_exec += ["--dir", tap_dir.to_s] if tap_dir
end end
end end
success = system(*srb_exec) success = system(*srb_exec)