cmd/info: generate --json=v2 from local taps.

Fixes #14541

Co-authored-by: Issy Long <issyl0@github.com>
This commit is contained in:
Mike McQuaid 2023-02-07 15:03:56 +01:00
parent ff5e517949
commit dbf02366b2
No known key found for this signature in database
GPG Key ID: 3338A31AFDB1D829

View File

@ -222,6 +222,14 @@ module Homebrew
formulae.map(&:to_hash)
end
when :v2
# Cannot generate cask API JSON data from the cask JSON API
if EnvConfig.install_from_api?
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
core_untapped = !CoreTap.instance.installed?
cask_untapped = !Tap.fetch("Homebrew/homebrew-cask").installed?
raise UsageError, "tap homebrew/core and/or homebrew/cask to use --json=v2" if core_untapped || cask_untapped
end
formulae, casks = if all
[Formula.all.sort, Cask::Cask.all.sort_by(&:full_name)]
elsif args.installed?