Merge pull request #13067 from Homebrew/any_casks_installed

caskroom: add, use any_casks_installed?.
This commit is contained in:
Mike McQuaid 2022-03-30 18:01:46 +01:00 committed by GitHub
commit b2f3081853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -12,7 +12,14 @@ module Cask
sig { returns(Pathname) }
def self.path
@path ||= HOMEBREW_PREFIX.join("Caskroom")
@path ||= HOMEBREW_PREFIX/"Caskroom"
end
sig { returns(T::Boolean) }
def self.any_casks_installed?
return false unless path.exist?
path.children.select(&:directory?).any?
end
sig { void }
@ -36,7 +43,7 @@ module Cask
def self.casks(config: nil)
return [] unless path.exist?
Pathname.glob(path.join("*")).sort.select(&:directory?).map do |path|
path.children.select(&:directory?).sort.map do |path|
token = path.basename.to_s
if (tap_path = CaskLoader.tap_paths(token).first)

View File

@ -48,7 +48,7 @@ module Homebrew
check_missing_deps
]
methods = (checks.all - slow_checks) + slow_checks
methods -= checks.cask_checks if Cask::Caskroom.casks.blank?
methods -= checks.cask_checks unless Cask::Caskroom.any_casks_installed?
else
methods = args.named
end

View File

@ -113,7 +113,7 @@ module Homebrew
ohai "Formulae" if $stdout.tty? && !args.formula?
safe_system "ls", *ls_args, HOMEBREW_CELLAR
end
if !args.formula? && Cask::Caskroom.casks.any?
if !args.formula? && Cask::Caskroom.any_casks_installed?
if $stdout.tty? && !args.cask?
puts
ohai "Casks"