-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
65 lines (58 loc) · 1.84 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2017 Telefónica Digital España S.L.
//
// This file is part of UrboCore API.
//
// UrboCore API is free software: you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// UrboCore API is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
// General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with UrboCore API. If not, see http://www.gnu.org/licenses/.
//
// For those usages not covered by this license please contact with
// iot_support at tid dot es
var gulp = require('gulp');
var batch = require('gulp-batch');
var watch = require('gulp-watch');
var spawn = require('child_process').spawn;
var node;
gulp.task('start', function() {
if (node) {
node.kill('SIGKILL');
}
node = spawn('node', ['./bin/www'], {stdio: 'inherit'});
node.on('close', function(code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
});
gulp.task('debug', function() {
if (node) {
node.kill('SIGKILL');
}
node = spawn('node', ['--inspect', '--debug-brk', './bin/www'], {stdio: 'inherit'});
node.on('close', function(code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
});
gulp.task('start-dev', ['debug'], function () {
watch('./**(?!node_modules\b)/*.js', batch(function(events, done) {
gulp.start('debug', done);
}));
});
gulp.task('default', ['start']);
// clean up if an error goes unhandled.
process.on('exit', function() {
if (node) {
node.kill()
}
});