Skip to content

Commit

Permalink
dev-cmd/typecheck: Use Sorbet's --dir to set the tap path
Browse files Browse the repository at this point in the history
- This means we don't have to copy config files around,
  and users get instant results rather than having
  to run `srb init`.
  • Loading branch information
issyl0 committed Aug 13, 2024
1 parent 807093f commit 399abae
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Library/Homebrew/dev-cmd/typecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ class Typecheck < AbstractCommand

sig { override.void }
def run
raise UsageError, "Cannot use --dir when specifying a tap." if args.named.present? && args.dir.present?

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"]
Homebrew.install_bundler_gems!(groups:)

# 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

directory.cd do
HOMEBREW_LIBRARY_PATH.cd do
if update
workers = args.debug? ? ["--workers=1"] : []
safe_system "bundle", "exec", "tapioca", "dsl", *workers
Expand Down Expand Up @@ -96,10 +97,11 @@ def run
end

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
srb_exec += ["--file", "../#{args.file}"] if args.file
srb_exec += ["--dir", "../#{args.dir}"] if args.dir
srb_exec += ["--dir", tap_dir.to_s] if tap_dir
end
end
success = system(*srb_exec)
Expand Down

0 comments on commit 399abae

Please sign in to comment.