forbidden-license: include method in module scope for module-wide access

This commit is contained in:
lionellloh 2020-07-07 16:09:20 +08:00 committed by Lionell
parent d24f911410
commit a161829927
2 changed files with 22 additions and 13 deletions

View File

@ -342,10 +342,13 @@ module Homebrew
rescue CannotInstallFormulaError => e
ofail e.message
end
def get_forbidden_licenses
Homebrew::EnvConfig.forbidden_licenses.split(" ")
end
def forbidden_license_check(f)
forbidden_licenses = ENV["HOMEBREW_FORBIDDEN_LICENSES"].split(" ")
forbidden_licenses = get_forbidden_licenses
if forbidden_licenses.include? f.license
raise CannotInstallFormulaError, <<~EOS
@ -363,3 +366,7 @@ def forbidden_license_check(f)
EOS
end
end
end

View File

@ -148,6 +148,8 @@ class FormulaInstaller
def prelude
Tab.clear_cache
verify_deps_exist unless ignore_deps?
Homebrew.forbidden_license_check(formula) unless ENV["HOMEBREW_FORBIDDEN_LICENSES"].blank?
check_install_sanity
end