This repository has been archived by the owner on May 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (57 loc) · 1.7 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
const child = require('child_process');
const gulp = require('gulp');
const less = require('gulp-less');
const path = require('path');
const sequence = require('run-sequence');
const util = require('gulp-util');
var server;
gulp.task('default', ['go', 'watch']);
gulp.task('watch', ['watch:less', 'watch:go']);
gulp.task('go', function(callback) { sequence('go:build', 'go:start', callback); });
gulp.task('go:build', function() {
if (server) {
server.kill();
}
var build = child.spawnSync('go', ['install']);
if (build.stderr.length) {
var lines = build.stderr.toString()
.split('\n').filter(function(line) {
return line.length
});
for (var l in lines)
util.log(util.colors.red(
'Error (go install): ' + lines[l]
));
}
return build;
});
gulp.task('go:start', function() {
if (server) {
server.kill();
}
server = child.spawn(process.env.GOPATH + '/bin/Data-Board.exe');
/* Pretty print server log output */
server.stdout.on('data', function(data) {
var lines = data.toString().split('\n')
for (var l in lines)
if (lines[l].length)
util.log(lines[l]);
});
/* Print errors to stdout */
server.stderr.on('data', function(data) {
process.stdout.write(data.toString());
});
});
gulp.task('watch:go', function() {
gulp.watch(['./**/*.go'], ['go:build', 'go:start']);
});
gulp.task('watch:less', function() {
gulp.watch(['./static/style/*.less'], ['less']);
});
gulp.task('less', function() {
return gulp.src('./static/style/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(gulp.dest('./static/style'));
});