-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
43 lines (37 loc) · 1.16 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
const gulp = require("gulp");
const spawn = require("child_process").spawn;
const server = require("gulp-develop-server");
const ts = require("gulp-typescript");
const sourcemaps = require("gulp-sourcemaps");
const tsProject = ts.createProject("tsconfig.json");
function compile() {
return (
tsProject
.src()
// .pipe(sourcemaps.init())
.pipe(tsProject())
.js // .pipe(sourcemaps.write())
.pipe(gulp.dest(tsProject.options.outDir))
);
}
gulp.task("compile", compile);
gulp.task("restart", server.restart);
gulp.task(
"watch",
gulp.series("compile", () => {
server.listen({ path: "output/main.js" });
gulp.watch("server/**/*", gulp.task("compile"));
gulp.watch("output/**/*", gulp.task("restart"));
}),
);
gulp.task("default", () => {
let app = spawn("npm", ["start", "--color"], { detached: true });
app.stdout.pipe(process.stdout);
app.stderr.pipe(process.stderr);
process.on("SIGINT", terminate);
process.on("SIGTERM", terminate);
function terminate() {
// kills the entire processes group
process.kill(-app.pid);
}
});