Support font sharding in Homebrew/cask

This commit is contained in:
Justin Krehel 2024-05-09 20:15:48 -04:00
parent 9bf7734749
commit 836d819c43
No known key found for this signature in database
GPG Key ID: 757F1864C8CF3605
2 changed files with 12 additions and 1 deletions

View File

@ -817,7 +817,11 @@ module Cask
def audit_cask_path def audit_cask_path
return unless cask.tap.core_cask_tap? return unless cask.tap.core_cask_tap?
expected_path = cask.tap.new_cask_path(cask.token) expected_path = if cask.artifacts.any?(Artifact::Font)
cask.tap.new_cask_font_path(cask.token)
else
cask.tap.new_cask_path(cask.token)
end
return if cask.sourcefile_path.to_s.end_with?(expected_path) return if cask.sourcefile_path.to_s.end_with?(expected_path)

View File

@ -1401,6 +1401,13 @@ class CoreCaskTap < AbstractCoreTap
cask_dir/cask_subdir/"#{token.downcase}.rb" cask_dir/cask_subdir/"#{token.downcase}.rb"
end end
sig { params(token: String).returns(Pathname) }
def new_cask_font_path(token)
font_first_letter = T.must(token.split("font-").second)[0].to_s
cask_subdir = "fonts/font-#{font_first_letter}"
cask_dir/cask_subdir/"#{token.downcase}.rb"
end
sig { override.returns(T::Array[Pathname]) } sig { override.returns(T::Array[Pathname]) }
def cask_files def cask_files
return super if Homebrew::EnvConfig.no_install_from_api? return super if Homebrew::EnvConfig.no_install_from_api?