-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
39 lines (34 loc) · 832 Bytes
/
gulpfile.js
File metadata and controls
39 lines (34 loc) · 832 Bytes
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
37
38
39
const {
task,
watch,
src,
parallel,
} = require('gulp');
const eslint = require('gulp-eslint');
const cache = require('gulp-cached');
const { spawn } = require('child_process');
const { log } = console;
let node;
const entry = 'src/index.js';
const lintPaths = ['src/**/*.js', 'scripts/**/*.js'];
const watchPaths = ['src/**/*.js', 'scripts/**/*.js'];
const serve = async () => {
if (node) node.kill();
node = await spawn('node', [entry], { stdio: 'inherit' });
node.on('close', (code) => {
if (code === 8) {
log('Error detected, waiting for changes...');
}
});
};
const lint = () => src(lintPaths)
.pipe(cache('lint'))
.pipe(eslint())
.pipe(eslint.format());
task('default', () => {
watch(
watchPaths,
{ queue: false, ignoreInitial: false },
parallel([serve, lint]),
);
});