-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
23 lines (17 loc) · 696 Bytes
/
dev.js
File metadata and controls
23 lines (17 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as fs from "node:fs";
import { setTimeout } from "node:timers/promises";
import { Cmds } from "@weedzcokie/concurrent-cmd";
fs.rmSync("./dist", { recursive: true });
const newProcessEnv = { ...process.env, FORCE_COLOR: "true" };
const ccmds = new Cmds(undefined, newProcessEnv);
ccmds.spawnCommand("./node_modules/.bin/tsc", ["--watch", "--preserveWatchOutput"]);
// Wait for TSC to produce code
while (!fs.existsSync("./dist")) {
await setTimeout(100);
}
ccmds.spawnCommand("node", ["--watch", "dist/main.js"]);
process.on("SIGINT", async (code) => {
console.log("Recieved SIGINT signal.");
await Promise.allSettled(ccmds.killChildren(code));
process.exit(0);
});