From 36a5aed7670d5d765317f7d6d3525c4b4664d224 Mon Sep 17 00:00:00 2001 From: Suguru Motegi Date: Sun, 11 Jun 2017 18:09:22 -0700 Subject: [PATCH] chore(gulp): clean up gulp tasks [ci skip] --- gulp/tasks/changelog.js | 8 ++++---- gulp/tasks/gh-pages.js | 8 ++++---- gulp/tasks/jsbeautifier.js | 4 ++-- gulp/tasks/jscs.js | 2 +- gulp/tasks/jsdoc.js | 4 ++-- gulp/tasks/perf.js | 25 ------------------------- gulp/tasks/release.js | 3 +-- 7 files changed, 14 insertions(+), 40 deletions(-) delete mode 100644 gulp/tasks/perf.js diff --git a/gulp/tasks/changelog.js b/gulp/tasks/changelog.js index 2846426c..455b3b4e 100644 --- a/gulp/tasks/changelog.js +++ b/gulp/tasks/changelog.js @@ -8,13 +8,13 @@ const generator = require('changelog-generator'); const async = require('../../'); -gulp.task('changelog', (done) => { - let filepath = path.resolve(__dirname, '../..', 'package.json'); - let url = require(filepath).homepage; +gulp.task('changelog', done => { + const filepath = path.resolve(__dirname, '../..', 'package.json'); + const { homepage } = require(filepath); async.angelFall([ - async.apply(generator, url), + async.apply(generator, homepage), async.apply(git.exec, { args: 'add ./CHANGELOG.md' diff --git a/gulp/tasks/gh-pages.js b/gulp/tasks/gh-pages.js index 3b6d5cc0..337c6a26 100644 --- a/gulp/tasks/gh-pages.js +++ b/gulp/tasks/gh-pages.js @@ -9,13 +9,13 @@ const git = require('gulp-git'); const async = require('../../'); const jsdoc = require('./jsdoc'); -gulp.task('gh-pages', (done) => { +gulp.task('gh-pages', done => { - let filepath = path.resolve(__dirname, '../..', 'lib/async.js'); - let options = { + const filepath = path.resolve(__dirname, '../..', 'lib/async.js'); + const options = { encoding: 'utf8' }; - let asyncFile = fs.readFileSync(filepath, options); + const asyncFile = fs.readFileSync(filepath, options); async.angelFall([ async.apply(git.fetch, 'origin', ''), diff --git a/gulp/tasks/jsbeautifier.js b/gulp/tasks/jsbeautifier.js index ae86ea9d..d4dae934 100644 --- a/gulp/tasks/jsbeautifier.js +++ b/gulp/tasks/jsbeautifier.js @@ -10,8 +10,8 @@ const config = require('../config'); gulp.task('jsfmt', ['jsbeautifier']); gulp.task('jsbeautifier', () => { - let dirnames = config.jsbeautifier.dirnames; - let streams = _.map(dirnames, (task) => { + const { dirnames } = config.jsbeautifier; + const streams = _.map(dirnames, task => { let dirname = task.slice(0, _.lastIndexOf(task, '/')); return gulp.src(task) .pipe(jsbeautifier({ diff --git a/gulp/tasks/jscs.js b/gulp/tasks/jscs.js index 015c98e9..828295e9 100644 --- a/gulp/tasks/jscs.js +++ b/gulp/tasks/jscs.js @@ -6,7 +6,7 @@ const jscs = require('gulp-jscs'); const config = require('../config'); gulp.task('jscs', () => { - let dirnames = config.jscs.dirnames; + const { dirnames } = config.jscs; return gulp.src(dirnames) .pipe(jscs('.jscsrc')); }); diff --git a/gulp/tasks/jsdoc.js b/gulp/tasks/jsdoc.js index 19eb5f83..a257d0de 100644 --- a/gulp/tasks/jsdoc.js +++ b/gulp/tasks/jsdoc.js @@ -11,8 +11,8 @@ const config = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../..', '.jsd })); function createJSDoc(done) { - let dirpath = path.resolve(__dirname, '../..', config.opts.destination); - exec('rm -rf ' + dirpath); + const dirpath = path.resolve(__dirname, '../..', config.opts.destination); + exec(`rm -rf ${dirpath}`); exec('$(npm bin)/jsdoc -c .jsdocrc ./lib/async.js', done); } diff --git a/gulp/tasks/perf.js b/gulp/tasks/perf.js deleted file mode 100644 index 2e854fb9..00000000 --- a/gulp/tasks/perf.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const _ = require('lodash'); -const exec = require('child_process').exec; -const es = require('event-stream'); - -const gulp = require('gulp'); -const gutil = require('gulp-util'); - -gulp.task('perf', () => { - let filename = gutil.env.file || '*'; - let gc = !!gutil.env.gc; - - gulp.src([ - './perf/func-comparator/**/sample.' + filename + '.js' - ]) - .pipe(es.map((file, next) => { - let filepath = _.first(file.history); - let command = ['node', gc ? '--expose_gc' : '', filepath].join(' '); - exec(command, (err, result) => { - console.log(result); - next(err); - }); - })); -}); diff --git a/gulp/tasks/release.js b/gulp/tasks/release.js index 011d4f80..161f408c 100644 --- a/gulp/tasks/release.js +++ b/gulp/tasks/release.js @@ -25,8 +25,7 @@ _.forEach(types, type => { 'release:dist', 'release:commit', 'release:tag', - 'gh-pages', - 'changelog' + 'gh-pages' )); });