2018-05-29 05:24:23 +02:00
|
|
|
/*
|
|
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
* license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright
|
|
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
* not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
|
|
|
|
2018-04-20 21:13:41 +02:00
|
|
|
import { getInstalledPackages } from '../src/dev/npm';
|
2017-05-24 17:34:55 +02:00
|
|
|
import {
|
2018-04-20 21:13:41 +02:00
|
|
|
assertLicensesValid,
|
|
|
|
LICENSE_WHITELIST,
|
|
|
|
LICENSE_OVERRIDES,
|
|
|
|
} from '../src/dev/license_checker';
|
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 {
|
2018-06-12 18:15:44 +02:00
|
|
|
const dev = Boolean(grunt.option('dev'));
|
|
|
|
|
2017-05-24 17:34:55 +02:00
|
|
|
assertLicensesValid({
|
|
|
|
packages: await getInstalledPackages({
|
|
|
|
directory: grunt.config.get('root'),
|
2018-06-12 18:15:44 +02:00
|
|
|
licenseOverrides: LICENSE_OVERRIDES,
|
|
|
|
dev
|
2017-05-24 17:34:55 +02:00
|
|
|
}),
|
2018-04-20 21:13:41 +02:00
|
|
|
validLicenses: LICENSE_WHITELIST
|
2017-05-24 17:34:55 +02:00
|
|
|
});
|
|
|
|
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
|
|
|
}
|