Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OSS analysis JSUnconf 2017
'use strict';
const licenseChecker = require('license-checker');
const exclude = `MIT,MIT*,ISC,WTFPL,(WTFPL OR MIT),(BSD-2-Clause OR MIT),(MIT AND CC-BY-3.0),Apache 2.0,Apache-2.0,(MIT OR Apache-2.0),BSD,BSD-2-Clause,BSD-3-Clause,
(BSD-2-Clause OR MIT OR Apache-2.0),Unlicense,Public Domain,Artistic-2.0,CC-BY-3.0`;
const dependenciesWhitelist = [/*{
name: 'json-schema@0.2.3',
reason: 'Invalid package.json field (uses licenses), but code is actually (BSD-3-Clause OR AFL-2.1)',
link: 'https://github.com/kriszyp/json-schema/pull/73'
}*/];
licenseChecker.init({
exclude,
production: true,
start: '.'
}, (err, result) => {
if (err) {
console.error(err);
} else {
Object.keys(result).filter(key => {
if (dependenciesWhitelist.some(dependency => dependency.name === key)) {
delete result[key];
}
});
if (Object.keys(result).length > 0) {
console.log(licenseChecker.asTree(result));
process.exit(1);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment