2017-05-24 17:34:55 +02:00
|
|
|
import {
|
|
|
|
getInstalledPackages,
|
|
|
|
assertLicensesValid
|
|
|
|
} from './lib';
|
2016-06-21 00:17:59 +02:00
|
|
|
|
|
|
|
export default function licenses(grunt) {
|
|
|
|
grunt.registerTask('licenses', 'Checks dependency licenses', async function () {
|
|
|
|
const done = this.async();
|
|
|
|
|
2017-05-24 17:34:55 +02:00
|
|
|
try {
|
|
|
|
const options = this.options({
|
|
|
|
licenses: [],
|
|
|
|
overrides: {}
|
2016-06-21 00:17:59 +02:00
|
|
|
});
|
2015-07-28 02:13:45 +02:00
|
|
|
|
2017-05-24 17:34:55 +02:00
|
|
|
assertLicensesValid({
|
|
|
|
packages: await getInstalledPackages({
|
|
|
|
directory: grunt.config.get('root'),
|
|
|
|
licenseOverrides: options.overrides
|
|
|
|
}),
|
|
|
|
validLicenses: options.licenses
|
|
|
|
});
|
|
|
|
done();
|
|
|
|
} catch (err) {
|
|
|
|
grunt.fail.fatal(err);
|
|
|
|
done(err);
|
2016-06-21 00:17:59 +02:00
|
|
|
}
|
2015-06-04 22:47:57 +02:00
|
|
|
});
|
2016-12-14 02:17:47 +01:00
|
|
|
}
|