This repository has been archived by the owner on Aug 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
101 lines (86 loc) · 2.49 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var gulp = require("gulp");
var gutil = require("gulp-util");
var pump = require("pump");
var ts = require("gulp-typescript");
var sourcemaps = require("gulp-sourcemaps");
var jeditor = require("gulp-json-editor");
var tslint = require("gulp-tslint");
var del = require("del");
var path = require("path");
var cp = require("child_process");
// Helper
function spawn(command, args, done) {
const child = cp.spawn(command, args, {
cwd: __dirname
});
child.stdout.on("data", (data) => {
gutil.log(data.toString().trim());
});
child.stderr.on("data", (data) => {
gutil.log(gutil.colors.red(data.toString().trim()));
});
child.on("error", (error) => {
gutil.log(gutil.colors.red(error));
});
child.on("exit", (code) => {
if (code === 0) {
done();
} else {
done(code);
}
});
}
// Tasks
gulp.task("lint", (done) => {
pump([
gulp.src(["./src/*.ts", "./src/**/*.ts", "./test/**/*.ts", "./test/*.ts"]),
tslint(),
tslint.report()
], done);
});
gulp.task("compile", (done) => {
const tsProject = ts.createProject("./tsconfig.json");
pump([
tsProject.src(),
sourcemaps.init(),
tsProject(),
sourcemaps.write(".", {
mapSources: (sourcePath, file) => {
// Correct source map path.
const relativeSourcePath = path.relative(path.dirname(file.path), path.join(file.base, sourcePath));
return relativeSourcePath;
}
}),
gulp.dest("out")
], done);
});
gulp.task("test", (done) => {
spawn("node", ["./node_modules/vscode/bin/test"], done);
});
gulp.task('cover:enable', (done) => {
pump([
gulp.src("./coverconfig.json"),
jeditor(function(json) {
json.enabled = true;
return json; // must return JSON object.
}),
gulp.dest("./", {'overwrite':true})
], done);
});
gulp.task('cover:disable', (done) => {
pump([
gulp.src("./coverconfig.json"),
jeditor(function(json) {
json.enabled = false;
return json; // must return JSON object.
}),
gulp.dest("./", {'overwrite':true})
], done);
});
gulp.task("clean", (done) => {
return del(['out', 'coverage'], done);
});
gulp.task("build", gulp.series("clean", "compile"));
gulp.task("watch", () => {
gulp.watch(["./src/*.ts", "./src/**/*.ts", "./test/**/*.ts", "./test/*.ts"], gulp.series("compile"));
});