From 706f495e79ca8cadd0bcca3486d69bf82e6baaf4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 29 Dec 2016 18:29:58 +0900 Subject: [PATCH] :v: --- gulpfile.ts | 20 ++++++++++++++++---- src/web/about/pages/license.pug | 6 ++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gulpfile.ts b/gulpfile.ts index 2bc948296f..64ada61e4f 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -3,7 +3,7 @@ */ import * as fs from 'fs'; -import * as path from 'path'; +import * as Path from 'path'; import * as gulp from 'gulp'; import * as gutil from 'gulp-util'; import * as babel from 'gulp-babel'; @@ -71,9 +71,20 @@ function getLicenseHtml(path: string): string { .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); } +function getLicenseSectionHtml(path: string): string { + try { + const pkg = JSON.parse(fs.readFileSync(Path.parse(path).dir + '/package.json', 'utf-8')); + const licenseHtml = getLicenseHtml(path); + return `
${pkg.name} v${pkg.version}${licenseHtml}
`; + } catch (e) { + return null; + } +} + gulp.task('build:about:docs', () => { const licenses = glob.sync('./node_modules/**/LICENSE*'); - const licenseHtml = [getLicenseHtml('./LICENSE')].concat(licenses.map(license => getLicenseHtml(license))).join('
'); + const licenseHtml = getLicenseHtml('./LICENSE'); + const thirdpartyLicensesHtml = licenses.map(license => getLicenseSectionHtml(license)).join(''); const pugs = glob.sync('./src/web/about/pages/**/*.pug'); const streams = pugs.map(file => { const page = file.replace('./src/web/about/pages/', '').replace('.pug', ''); @@ -81,10 +92,11 @@ gulp.task('build:about:docs', () => { .pipe(pug({ locals: Object.assign({ path: page, - license: licenseHtml + license: licenseHtml, + thirdpartyLicenses: thirdpartyLicensesHtml }, config) })) - .pipe(gulp.dest('./built/web/about/pages/' + path.parse(page).dir)); + .pipe(gulp.dest('./built/web/about/pages/' + Path.parse(page).dir)); }); return es.merge.apply(es, streams); diff --git a/src/web/about/pages/license.pug b/src/web/about/pages/license.pug index eb008a3caf..2d91a00f53 100644 --- a/src/web/about/pages/license.pug +++ b/src/web/about/pages/license.pug @@ -7,3 +7,9 @@ block content h1 ライセンス div!= license + + hr + + details + summary サードパーティ + div!= thirdpartyLicenses