-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
36 lines (30 loc) · 751 Bytes
/
gulpfile.js
File metadata and controls
36 lines (30 loc) · 751 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
const gulp = require('gulp');
const spawn = require('child_process').spawn;
let node;
function server() {
if (node) {
node.kill();
}
node = spawn('node', ['src/server.js'], {stdio: 'inherit'});
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
}
gulp.task('server', function() {
server();
});
gulp.task('watch', ['server'], function() {
gulp.watch(['./src/**/*.js'], function() {
console.log('Change Detected. Restarting .......')
server();
});
});
gulp.task('default', ['watch']);
// clean up if an error goes unhandled.
process.on('exit', function() {
if (node) {
node.kill();
}
});