-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (54 loc) · 1.5 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
var gulp = require("gulp");
var colors = require("colors");
var exec = require("child_process").exec;
var path = require("path");
function out (string) {
var formattedTime = (new Date()).toTimeString().split(" ")[0];
console.log("["+formattedTime.gray+"] "+string);
}
function lint() {
return new Promise(function(resolve, reject) {
exec("npm run lint", function(err, stdout, stderr){
if (!stderr) {
out("Compiled Lint".blue);
resolve();
} else {
out("Error in Lint".red);
reject(stdout);
}
});
});
}
function tsc() {
return new Promise(function(resolve, reject) {
exec("npm run build", function(err, stdout, stderr){
if (!stderr) {
out("Compiled Build".blue);
resolve();
} else {
out("Error in Build".red);
reject(stdout);
}
});
});
}
function runCompilation() {
out("Compiling scripts..".yellow);
return lint()
.then(tsc)
.then(function(){
return new Promise(function(resolve, reject) {
out("Compiling scripts done.".green);
});
})
.catch(function(err){
console.log(err);
});
}
gulp.task("watch-typescript", function(){
runCompilation();
gulp.watch("src/**/*.ts", function(event) {
runCompilation();
});
});
gulp.task("default", ["watch-typescript"]);