diff --git a/lib/index.js b/lib/index.js index d12c53d..ebf2a77 100644 --- a/lib/index.js +++ b/lib/index.js @@ -537,16 +537,22 @@ exports.init = function init(args, callback) { }; const checkForOnlyAllow = (currentLicense, packageName) => { - if (!Array.isArray(toCheckforOnlyAllow) || toCheckforOnlyAllow.length === 0) { - return; - } + if (toCheckforOnlyAllow.length > 0) { + let hasOnlyAllowedPackages = false; - if (!toCheckforOnlyAllow.includes(currentLicense)) { - console.error( - `Package "${packageName}" is licensed under "${currentLicense}" which is not permitted by the --onlyAllow flag. Exiting.`, - ); + toCheckforOnlyAllow.forEach((allowedLicense) => { + if (currentLicense.indexOf(allowedLicense) >= 0) { + hasOnlyAllowedPackages = true; + } + }); - process.exit(1); + if (!hasOnlyAllowedPackages) { + console.error( + `Package "${packageName}" is licensed under "${currentLicense}" which is not permitted by the --onlyAllow flag. Exiting.`, + ); + + process.exit(1); + } } };