-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
36 lines (31 loc) · 1.15 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
36
'use strict';
const {series, src, watch} = require('gulp');
const eslint = require('gulp-eslint-new');
const excludeGitignore = require('gulp-exclude-gitignore');
const plumber = require('gulp-plumber');
const jest = require('gulp-jest').default;
function lint() {
return src(['generators/*/*.js', 'test/**.js', 'utils/**.js', 'generators/*/templates/plain/**.js', 'generators/*/templates/sample_plain/**.js'])
.pipe(excludeGitignore())
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function lintWatch() {
watch(['generators/*/*.js', 'test/**.js', 'utils/**.js', 'generators/*/templates/plain/**.js', 'generators/*/templates/sample_plain/**.js'], lint);
}
function runTest() {
process.env.NODE_ENV = 'test';
return src('test/')// using src('test/**/*.js') will cause the task to be run twice
.pipe(plumber())
.pipe(jest());
}
function testWatch() {
watch(['generators/*/*.js', 'test/**'], runTest);
}
exports.test = runTest;
exports.testWatch = series(runTest, testWatch);
exports.lint = lint;
exports.lintWatch = series(lint, lintWatch);
exports.prepublish = series(lint);
exports.default = series(lint, runTest);