-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
46 lines (39 loc) · 1.1 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
const gulp = require("gulp");
const plumber = require("gulp-plumber");
gulp.srcPlumber = function (...args) {
return gulp.src(...args)
.pipe(plumber());
}
const moduleCache = {};
function requireCache(moduleName) {
if (!(moduleName in moduleCache)) {
moduleCache[moduleName] = require(moduleName);
}
return moduleCache[moduleName];
}
let project;
gulp.task("ts", () => {
const typescript = requireCache("gulp-typescript");
const merge = requireCache("merge2");
if (!project) project = typescript.createProject("tsconfig.json");
const result = project.src()
.pipe(plumber())
.pipe(project());
return merge([
result.js.pipe(gulp.dest("out")),
result.dts.pipe(gulp.dest("out")),
]);
});
gulp.task("mocha", () => {
const mocha = requireCache("gulp-mocha");
gulp.src("out/tests/Main.js", { read: false })
.pipe(mocha({ reporter: "min" }))
.on("error", () => process.exitCode = 1);
});
gulp.task("compile-test", () => {
const runSequence = requireCache("run-sequence");
runSequence("ts", "mocha");
});
gulp.task("watch", ["compile-test"], () => {
gulp.watch("./src/**/*.ts", ["compile-test"]);
});