forked from finos/git-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
38 lines (30 loc) · 817 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
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const watchList = ['index.js', 'test/**', 'lib/**'];
let node = null;
const server = function(cb) {
const spawn = require('child_process').spawn;
if (node) {
node.kill();
}
node = spawn('node', ['index.js'], {stdio: 'inherit'});
cb();
node.on('close', (code) => {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
};
const runTest = function() {
return gulp.src(['test/**/*.js'], {read: false})
.pipe(mocha({reporter: 'list', exit: false}))
.on('error', console.error);
};
// clean up if an error goes unhandled.
process.on('exit', function() {
if (node) {
node.kill();
}
});
exports.server = server;
exports.test = () => gulp.watch(watchList, () => runTest());