Skip to content

Commit

Permalink
Support Tap#cask_files when using API.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 20, 2024
1 parent b8b2382 commit a320b9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
24 changes: 8 additions & 16 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -936,25 +936,17 @@ def check_cask_staging_location
end

def check_cask_taps
default_cask_tap = CoreCaskTap.instance
taps = Tap.select { |t| t.cask_dir.exist? && t != default_cask_tap }
taps.prepend(default_cask_tap) if EnvConfig.no_install_from_api?

error_tap_paths = []

add_info "Homebrew Cask Taps:", (taps.map do |tap|
if tap.path.blank?
none_string
else
cask_count = begin
tap.cask_files.count
rescue
error_tap_paths << tap.path
0
end

"#{tap.path} (#{Utils.pluralize("cask", cask_count, include_count: true)})"
add_info "Homebrew Cask Taps:", (Tap.map do |tap|
cask_count = begin
tap.cask_files.count
rescue
error_tap_paths << tap.path
0
end

"#{tap.path} (#{Utils.pluralize("cask", cask_count, include_count: true)})"
end)

taps_string = Utils.pluralize("tap", error_tap_paths.count)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1208,9 +1208,9 @@ def new_cask_path(token)

sig { override.returns(T::Array[Pathname]) }
def cask_files
return super if Homebrew::EnvConfig.no_install_from_api? || installed?
return super if Homebrew::EnvConfig.no_install_from_api?

raise TapUnavailableError, name
cask_files_by_name.values
end

sig { override.returns(T::Array[String]) }
Expand Down

0 comments on commit a320b9f

Please sign in to comment.