kibana/tasks/lib/notice/notice.js
Spencer 5c04ff65fb Remove use of npm ls in grunt tasks (#11965)
* [grunt/build] refactor _build:notice task to not depend on npm

The _build:notice task used to rely on the output of `npm ls` to determine where modules were defined, but the task now just asks `license-checker` to include the `realPath` of the modules it describes in it's output, which is ultimately the same thing but works with `yarn` too.

* [grunt/licenses] convert to use lib/packages/getInstalledPackages()

* [grunt/notice/generate] test generateNoticeText()

* [grunt/licenses] tested assertLicensesValid()

* [npm] remove npm dev dep

* [tasks/lib/packages] do not include kibana in "installed packages"

* [tasks/lib/notice] join all notices with the same separator
2017-05-24 08:34:55 -07:00

34 lines
1.1 KiB
JavaScript

import { resolve } from 'path';
import { readFileSync } from 'fs';
import { generatePackageNoticeText } from './package_notice';
import { generateNodeNoticeText } from './node_notice';
const BASE_NOTICE = resolve(__dirname, './base_notice.txt');
/**
* When given a list of packages and the directory to the
* node distribution that will be shipping with Kibana,
* generates the text for NOTICE.txt
*
* @param {Object} [options={}]
* @property {Array<Package>} options.packages List of packages to check, see
* getInstalledPackages() in ../packages
* @property {string} options.nodeDir The directory containing the version of node.js
* that will ship with Kibana
* @return {undefined}
*/
export async function generateNoticeText(options = {}) {
const { packages, nodeDir } = options;
const packageNotices = await Promise.all(
packages.map(generatePackageNoticeText)
);
return [
readFileSync(BASE_NOTICE, 'utf8'),
...packageNotices,
generateNodeNoticeText(nodeDir),
].join('\n---\n');
}