Skip to content

Commit

Permalink
chore(scripts/license-checker): handle old license arrays or missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Jan 24, 2024
1 parent 3e52e27 commit 3e651b6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions scripts/license-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,20 @@ async function checkLicenses() {
start: joinSafe(__dirname, ".."),
});

const copyLeftLicensesList = Object.keys(licenses).filter((license) =>
// @ts-ignore: includes() returns false if undefined is passed
copyLeftLicenses.includes(licenses[license].licenses)
);
const copyLeftLicensesList = Object.keys(licenses).filter((license) => {
let lic = licenses[license].licenses;

if (!lic) {
console.error(
`No license found for ${license}. Please check the package.json file.`
);
process.exit(1);
}

lic = Array.isArray(lic) ? lic : [lic];

return lic.some((l) => copyLeftLicenses.includes(l));
});

if (copyLeftLicensesList.length > 0) {
console.error(
Expand Down

0 comments on commit 3e651b6

Please sign in to comment.