Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

License whitelist #123

Open
jojomatik opened this issue Apr 15, 2022 · 1 comment
Open

License whitelist #123

jojomatik opened this issue Apr 15, 2022 · 1 comment

Comments

@jojomatik
Copy link

I've seen in the docs that unacceptableLicenseTest can be used to blacklist certain licenses.

To be totally safe though I'd like to be able to whitelist certain licenses, so that the build process fails if any other license is found.

Is this possible? Could this be implemented?

@lokanx
Copy link

lokanx commented Oct 31, 2022

You can do that with unacceptableLicenseTest easily, example that breaks the build if a non-white-listed license are found

const ACCEPTABLE_LICENSE_TYPES = [
  'MIT',
  'Apache-2.0',
  'ISC',
  'BSD-3-Clause'
];

...

 new LicenseWebpackPlugin({
   ...
   unacceptableLicenseTest: (licenseType) => !ACCEPTABLE_LICENSE_TYPES.includes(licenseType),
   handleUnacceptableLicense: (packageName, licenseType) => {
        console.error("Unacceptable license found: packageName=", packageName, ", licenseType=", licenseType);
        process.exit(-1);
   },
   ...
 })

I suggest you handle missing licenses in the same way, eg break the build on that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants