From d42990f0b37097d4291173de0265632b2f281df3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Jan 2017 01:28:11 +0900 Subject: [PATCH] Refactor --- gulpfile.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/gulpfile.ts b/gulpfile.ts index 7e4c5eb16..3be636fa9 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -70,24 +70,24 @@ gulp.task('build:ts', () => .pipe(gulp.dest('./built/')) ); -function getLicenseHtml(path: string): string { - return escapeHtml(fs.readFileSync(path, 'utf-8')) - .replace(/\r\n/g, '\n') - .replace(/(.)\n(.)/g, '$1 $2') - .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', () => { + function getLicenseHtml(path: string): string { + return escapeHtml(fs.readFileSync(path, 'utf-8')) + .replace(/\r\n/g, '\n') + .replace(/(.)\n(.)/g, '$1 $2') + .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; + } + } + const licenses = glob.sync('./node_modules/**/LICENSE*'); const licenseHtml = getLicenseHtml('./LICENSE'); const thirdpartyLicensesHtml = licenses.map(license => getLicenseSectionHtml(license)).join('');