-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
66 lines (57 loc) · 1.93 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
66
// Copyright 2017 Telefónica Digital España S.L.
//
// This file is part of UrboCore Processing.
//
// UrboCore Processing 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 Processing 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 Processing. 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
'use strict';
var gulp = require('gulp');
var batch = require('gulp-batch');
var watch = require('gulp-watch');
var babel = require("gulp-babel");
var insert = require('gulp-insert');
var spawn = require('child_process').spawn;
var node;
gulp.task("transpile", function () {
gulp.src(["./jobs/**/*.js6"])
.pipe(babel())
.pipe(insert.prepend("/**\n*\n* DO NOT EDIT THIS FILE. EDIT .js6 INSTEAD\n*\n*/\n\n"))
.pipe(gulp.dest("./jobs"));
});
gulp.task('start', function () {
if (node) {
node.kill('SIGKILL');
}
node = spawn('node', ['./bin/processing'], { stdio: 'inherit' });
node.on('close', function (code) {
if (code === 8) {
gulp.log('Error detected, waiting for changes...');
}
});
});
gulp.task('start-dev', ['start'], function () {
watch('./**/*.js', batch(function (events, done) {
gulp.start('transpile');
gulp.start('start', done);
}));
});
gulp.task('default', ['transpile', 'start']);
// clean up if an error goes unhandled.
process.on('exit', function () {
if (node) {
node.kill();
}
});