From f9f099a48c6586daaf232d34b600d1a31d8d1eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=BD=B6?= Date: Sun, 12 Feb 2017 01:28:00 +0800 Subject: [PATCH] =?UTF-8?q?v0.0.5=20=E4=BB=85=E6=A3=80=E6=9F=A5=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .babelrc | 4 ++-- README.md | 9 +++++++-- gulpfile.js | 28 +++++++++++++++++++++++----- package.json | 2 +- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.babelrc b/.babelrc index f0d8043..51a8ae4 100644 --- a/.babelrc +++ b/.babelrc @@ -1,4 +1,4 @@ { - 'presets': ['es2015', 'stage-2'], - 'plugins': ['transform-runtime'] + "presets": ["es2015", "stage-2"], + "plugins": ["transform-runtime"] } diff --git a/README.md b/README.md index 2627545..38a9b42 100644 --- a/README.md +++ b/README.md @@ -471,9 +471,14 @@ request.post('/api').form({key:'value'}), function(err,httpResponse,body){ /* .. 删除gulpfile.js中的lint、eslint_start两个任务,并且把default改为“gulp.task('default', ['start']”。 -## 更新说明 +更新说明 +-------- + +*v0.0.5 2017年02月12日01:25:34* +1、修改了gulpfile.js文件,在更改文件热重启的时候无需检查全部文件,仅检查改动文件,开发速度更快。 +2、修改了package.json中"start"项的值为"gulp nodemon"配合gulpfile.js文件的修改。 *v0.0.4 2017年02月07日15:57:17* 1、修改了部分配置文件的配置方法,使之更为规范(老版本用户无须理会,对程序没有影响)。 2、修改了eslintrc.js文件中的JavaScript版本配置,改为ES8,兼容async、await。 -3、修改gulpfile.js文件第12行,检查`src/**/*.js`文件。 +3、修改gulpfile.js文件第12行,检查`src/**/*.js`文件。 diff --git a/gulpfile.js b/gulpfile.js index e5ddbd0..7ce7dcf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,7 +8,22 @@ if (process.env.npm_config_argv.indexOf('debug') > 0) { jsScript = 'node debug' } -gulp.task('lint', () => { +function lintOne (aims) { + console.log('ESlint:' + aims) + console.time('Finished eslint') + return gulp.src(aims) + .pipe(eslint({configFile: './.eslintrc.js'})) + .pipe(eslint.format(friendlyFormatter)) + .pipe(eslint.results(results => { + // Called once for all ESLint results. + console.log(`- Total Results: ${results.length}`) + console.log(`- Total Warnings: ${results.warningCount}`) + console.log(`- Total Errors: ${results.errorCount}`) + console.timeEnd('Finished eslint') + })) +} + +gulp.task('ESlint', () => { return gulp.src(['src/**/*.js', '!node_modules/**']) .pipe(eslint({configFile: './.eslintrc.js'})) .pipe(eslint.format(friendlyFormatter)) @@ -21,13 +36,16 @@ gulp.task('lint', () => { })) }) -gulp.task('eslint_start', ['lint'], function () { +gulp.task('ESlint_nodemon', ['ESlint'], function () { var stream = nodemon({ script: 'build/dev-server.js', execMap: { js: jsScript }, - tasks: ['lint'], + tasks: function (changedFiles) { + lintOne(changedFiles) + return [] + }, verbose: true, ignore: ['build/*.js', 'dist/*.js', 'nodemon.json', '.git', 'node_modules/**/node_modules', 'gulpfile.js'], env: { @@ -46,7 +64,7 @@ gulp.task('eslint_start', ['lint'], function () { }) }) -gulp.task('start', function () { +gulp.task('nodemon', function () { return nodemon({ script: 'build/dev-server.js', execMap: { @@ -61,6 +79,6 @@ gulp.task('start', function () { }) }) -gulp.task('default', ['lint', 'eslint_start'], function () { +gulp.task('default', ['ESlint', 'ESlint_nodemon'], function () { // console.log('ESlin检查完成') }) diff --git a/package.json b/package.json index aa3b94b..a718bda 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Koa2 RESTful API 服务器的脚手架", "author": "轶哥 ", "scripts": { - "start": "gulp start", + "start": "gulp nodemon", "dev": "gulp", "build": "babel src -d dist", "production": "node dist/app.js"