From ce216d218bc1ef7934d5de033f8a6f9e556e16d6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 22 Feb 2017 10:49:11 +0900 Subject: Clean up :sparkles: --- gulpfile.ts | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'gulpfile.ts') diff --git a/gulpfile.ts b/gulpfile.ts index 00772925ef..f7503912ce 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -14,16 +14,13 @@ import * as es from 'event-stream'; import * as webpack from 'webpack-stream'; import cssnano = require('gulp-cssnano'); import * as uglify from 'gulp-uglify'; -import riotify = require('riotify'); import pug = require('gulp-pug'); import git = require('git-last-commit'); import * as rimraf from 'rimraf'; -import * as escapeHtml from 'escape-html'; import prominence = require('prominence'); import * as chalk from 'chalk'; import imagemin = require('gulp-imagemin'); import * as rename from 'gulp-rename'; -import named = require('vinyl-named'); const env = process.env.NODE_ENV; const isProduction = env === 'production'; @@ -33,6 +30,8 @@ if (isDebug) { console.log(chalk.yellow.bold('!!!注意!!! 開発モードが有効です。(成果物の圧縮などはスキップされます)')); } +const constants = require('./src/const.json'); + const tsProject = ts.createProject('tsconfig.json'); gulp.task('build', [ @@ -65,37 +64,22 @@ gulp.task('build:ts', () => gulp.task('build:about:docs', () => { function getLicenseHtml(path: string) { - return escapeHtml(fs.readFileSync(path, 'utf-8')) + return fs.readFileSync(path, 'utf-8') .replace(/\r\n/g, '\n') .replace(/(.)\n(.)/g, '$1 $2') .replace(/(^|\n)(.*?)($|\n)/g, '

$2

'); } - function getLicenseSectionHtml(path: 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(''); - const pugs = glob.sync('./docs/**/*.pug'); - const streams = pugs.map(file => { + const streams = glob.sync('./docs/**/*.pug').map(file => { const page = file.replace('./docs/', '').replace('.pug', ''); return gulp.src(file) .pipe(pug({ - locals: Object.assign({ + locals: { path: page, license: licenseHtml, - thirdpartyLicenses: thirdpartyLicensesHtml - }, { - themeColor: '#f76d6c' - }) + themeColor: constants.themeColor + } })) .pipe(gulp.dest('./built/web/about/pages/' + Path.parse(page).dir)); }); @@ -209,7 +193,7 @@ gulp.task('build:client:pug', [ gulp.src('./src/web/app/*/view.pug') .pipe(pug({ locals: { - themeColor: '#f76d6c' + themeColor: constants.themeColor } })) .pipe(gulp.dest('./built/web/app/')) -- cgit v1.2.3-freya