-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
35 lines (28 loc) · 1.13 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const forever = require('forever-monitor');
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const gulpIf = require('gulp-if');
// Use ESLint linting *.js files besides source files in node_modules
gulp.task('lint', () => gulp.src(['**/*.js', '!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError()));
function isFixed(file) {
return file.eslint != null && file.eslint.fixed;
}
// Use ESLint linting *.js files besides source files in node_modules and fix some simple errors.
gulp.task('lint-fix', () => gulp.src(['**/*.js', '!node_modules/**'])
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulpIf(isFixed, gulp.dest('.')))
.pipe(eslint.failAfterError()));
/**
* @summary Run unit test
*/
gulp.task('test', () => gulp.src(['tests/unit/*.js'])
.pipe(mocha({ reporter: 'spec' })));
// Start application using forever
gulp.task('start', () => new forever.Monitor('app.js').start());
// Run test and lint tasks in parallel before starting the application
gulp.task('run', gulp.series(gulp.parallel('lint', 'test'), 'start'));