Skip to content

Commit

Permalink
[tasks/lib/notice] join all notices with the same separator
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed May 23, 2017
1 parent e5a4839 commit a80c43e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion tasks/lib/notice/base_notice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ THE SOFTWARE.
---
This product bundles geohash.js which is available under a
"MIT" license. For details, see src/ui/public/utils/decode_geo_hash.js.
---
6 changes: 3 additions & 3 deletions tasks/lib/notice/notice.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolve } from 'path';
import { readFileSync } from 'fs';

import { generatePackagesNoticeText } from './packages_notice';
import { generatePackageNoticeTexts } from './packages_notice';
import { generateNodeNoticeText } from './node_notice';

const BASE_NOTICE = resolve(__dirname, './base_notice.txt');
Expand All @@ -22,7 +22,7 @@ export async function generateNoticeText(options = {}) {
const { packages, nodeDir } = options;
return [
readFileSync(BASE_NOTICE, 'utf8'),
await generatePackagesNoticeText(packages),
...(await generatePackageNoticeTexts(packages)),
generateNodeNoticeText(nodeDir)
].join('');
].join('\n---\n');
}
6 changes: 2 additions & 4 deletions tasks/lib/notice/packages_notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const concatNotices = notices => (
notices.map(notice => notice.text).join('\n')
);

export async function generatePackagesNoticeText(packages) {
const noticeChunks = await asyncMap(packages, async pkg => {
export async function generatePackageNoticeTexts(packages) {
return await asyncMap(packages, async pkg => {
const bundledNotices = concatNotices(await getBundledNotices(pkg.directory));

const intro = `This product bundles ${pkg.name}@${pkg.version}`;
Expand All @@ -23,6 +23,4 @@ export async function generatePackagesNoticeText(packages) {

return `${intro}${license}${moreInfo}`;
});

return noticeChunks.join('\n---\n');
}

0 comments on commit a80c43e

Please sign in to comment.