From c1bdbc53ea33b8f1083c0a531973da881c1d7d15 Mon Sep 17 00:00:00 2001 From: lionellloh Date: Thu, 9 Jul 2020 17:45:04 +0800 Subject: [PATCH] include logic for ignore-deps and only-deps --- Library/Homebrew/formula_installer.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index a86867c2af..2d7eeba674 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1110,19 +1110,22 @@ class FormulaInstaller forbidden_licenses = Homebrew::EnvConfig.forbidden_licenses.to_s.split(" ") return if forbidden_licenses.blank? - if forbidden_licenses.include? formula.license - raise CannotInstallFormulaError, <<~EOS - #{formula.name} has a forbidden license #{formula.license}. - EOS - end - compute_dependencies.each do |dep, _| + next if @ignore_deps + dep_f = dep.to_formula next unless forbidden_licenses.include? dep_f.license raise CannotInstallFormulaError, <<~EOS - The installation of #{f.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}. + The installation of #{formula.name} has a dependency on #{dep.name} with a forbidden license #{dep_f.license}. EOS end + return if @only_deps + + return unless forbidden_licenses.include? formula.license + + raise CannotInstallFormulaError, <<~EOS + #{formula.name} has a forbidden license #{formula.license}. + EOS end end