-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
44 lines (37 loc) · 945 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
'use strict';
var gulp = require('gulp');
var apidoc = require('gulp-apidoc');
var ghPages = require('gulp-gh-pages');
var spawn = require('child_process').spawn,
node;
gulp.task('apidoc', function() {
apidoc.exec({
src: "backend/routes/",
dest: "backend/apidoc/"
});
});
/**
* $ gulp server
* description: launch the server. If there's a server already running, kill it.
*/
gulp.task('server', function() {
if (node) node.kill()
node = spawn('node', ['backend/app.js'], {stdio: 'inherit'})
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
})
gulp.task('watch', function(){
gulp.watch(['backend/**/*.js'], ['server']);
})
/**
* $ gulp
* description: start the development environment
*/
gulp.task('default', ['server','watch']);
// clean up if an error goes unhandled.
process.on('exit', function() {
if (node) node.kill()
})