Skip to content

Instantly share code, notes, and snippets.

@timbru31
Last active April 6, 2017 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timbru31/52a65042eba6e01830a123380ca9dcae to your computer and use it in GitHub Desktop.
Save timbru31/52a65042eba6e01830a123380ca9dcae to your computer and use it in GitHub Desktop.
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