From e54e719e38877571152177f26a63793985ff7e6f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 18 Nov 2020 09:57:45 +0100 Subject: [PATCH] Add `Cask::Cmd::Audit.audit_casks` method. --- Library/Homebrew/cask/cmd/audit.rb | 58 +++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index 3655f0313d..4d5f563ccf 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -42,23 +42,6 @@ module Cask sig { void } def run - require "cask/auditor" - - Homebrew.auditing = true - - options = { - audit_download: args.download?, - audit_appcast: args.appcast?, - audit_online: args.online?, - audit_strict: args.strict?, - audit_new_cask: args.new_cask?, - audit_token_conflicts: args.token_conflicts?, - quarantine: args.quarantine?, - language: args.language, - }.compact - - options[:quarantine] = true if options[:quarantine].nil? - casks = args.named.flat_map do |name| next name if File.exist?(name) next Tap.fetch(name).cask_files if name.count("/") == 1 @@ -68,6 +51,47 @@ module Cask casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) } casks = Cask.to_a if casks.empty? + self.class.audit_casks( + *casks, + download: args.download?, + appcast: args.appcast?, + online: args.online?, + strict: args.strict?, + new_cask: args.new_cask?, + token_conflicts: args.token_conflicts?, + quarantine: args.quarantine?, + language: args.language, + ) + end + + def self.audit_casks( + *casks, + download: nil, + appcast: nil, + online: nil, + strict: nil, + new_cask: nil, + token_conflicts: nil, + quarantine: nil, + language: nil + ) + options = { + audit_download: download, + audit_appcast: appcast, + audit_online: online, + audit_strict: strict, + audit_new_cask: new_cask, + audit_token_conflicts: token_conflicts, + quarantine: quarantine, + language: language, + }.compact + + options[:quarantine] = true if options[:quarantine].nil? + + Homebrew.auditing = true + + require "cask/auditor" + failed_casks = casks.reject do |cask| odebug "Auditing Cask #{cask}" result = Auditor.audit(cask, **options)