-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
47 lines (38 loc) · 890 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
45
46
47
const gulp = require('gulp');
$ = require('gulp-load-plugins')({
pattern: ['gulp-*', 'run-sequence']
});
const spawn = require('child_process').spawn;
let node;
function server() {
if (node) {
node.kill();
}
node = spawn('node', ['src/bot.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('lint', function () {
gulp.src('src/**/*.js')
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failAfterError());
});
gulp.task('watch', ['server'], function () {
gulp.watch(['./src/**/*.js'], ['lint', function () {
server();
}]);
});
gulp.task('default', ['watch']);
// clean up if an error goes unhandled.
process.on('exit', function () {
if (node) {
node.kill();
}
});