diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 10:49:11 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-22 10:49:11 +0900 |
| commit | ce216d218bc1ef7934d5de033f8a6f9e556e16d6 (patch) | |
| tree | 65f4c39f4490922bef6a762271b5ea2bc54f88e7 /gulpfile.ts | |
| parent | Add 親切なエラーメッセージ (diff) | |
| download | sharkey-ce216d218bc1ef7934d5de033f8a6f9e556e16d6.tar.gz sharkey-ce216d218bc1ef7934d5de033f8a6f9e556e16d6.tar.bz2 sharkey-ce216d218bc1ef7934d5de033f8a6f9e556e16d6.zip | |
Clean up :sparkles:
Diffstat (limited to 'gulpfile.ts')
| -rw-r--r-- | gulpfile.ts | 32 |
1 files changed, 8 insertions, 24 deletions
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, '<p>$2</p>'); } - function getLicenseSectionHtml(path: string) { - try { - const pkg = JSON.parse(fs.readFileSync(Path.parse(path).dir + '/package.json', 'utf-8')); - const licenseHtml = getLicenseHtml(path); - return `<details><summary>${pkg.name} <small>v${pkg.version}</small></summary>${licenseHtml}</details>`; - } 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/')) |