I'm experimenting with the license-checker library to filter and throw on certain license types. In the README, there is an example of how to interrogate the JSON data with some unexpected characters:
var checker = require('license-checker');
checker.init({
start: '/path/to/start/looking'
}, function(json, err) {
if (err) {
//Handle error
} else {
//The sorted json data
}
});
However, when I look at the format of that JSON, I'm not sure how I would pull it a part to evaluate the licenses. Here's an example of the structure:
{ 'ansi-styles@1.1.0':
{ licenses: 'MIT',
repository: 'https://github.com/sindresorhus/ansi-styles' },
'ansi-styles@2.1.0':
{ licenses: 'MIT',
repository: 'git+https://github.com/chalk/ansi-styles',
licenseFile: '...' },
'ansi-wrap@0.1.0':
{ licenses: 'MIT',
repository: 'git+https://github.com/jonschlinkert/ansi-wrap',
licenseFile: '...' },
...
How can I examine that json variable passed into the checker function to compare the licenses property against a license whitelist array?