Skip to content

Commit

Permalink
fix: Revert breaking refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Seidelsohn committed Oct 13, 2023
1 parent 72ebae0 commit 94a363a
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};

Expand Down

0 comments on commit 94a363a

Please sign in to comment.