-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
44 lines (36 loc) · 958 Bytes
/
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
37
38
39
40
41
42
43
44
const gulp = require('gulp');
const { spawn } = require('child_process');
const watchedPaths = [
'src/**/*.js',
'src/**/*.graphql',
];
let node;
gulp.task('serve', ['lint'], function (cb) {
if (node) node.kill();
node = spawn('node', ['src/index.js'], { stdio: 'inherit' });
node.on('close', function (code) {
if (code === 8) {
cb(code);
console.log('Error detected, waiting for changes...');
}
});
cb();
});
gulp.task('watch', function () {
gulp.watch(watchedPaths, ['serve']);
});
gulp.task('lint', function (cb) {
const lint = spawn('./node_modules/.bin/eslint', ['--cache', 'src'], { stdio: 'inherit' });
lint.on('close', function (code) {
if (code === 8) {
cb(code);
gulp.log('Error detected, waiting for changes...');
}
cb();
});
});
gulp.task('default', ['watch', 'serve']);
// clean up if an error goes unhandled.
process.on('exit', function () {
if (node) node.kill();
});