-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
26 lines (21 loc) · 739 Bytes
/
Copy pathdev.js
File metadata and controls
26 lines (21 loc) · 739 Bytes
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
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);
void ccmds.spawnCommand("./node_modules/.bin/tsc", [
"--watch",
"--preserveWatchOutput",
]);
// Wait for TSC to produce code
// eslint-disable no-await-in-loop
while (!fs.existsSync("./dist")) {
await setTimeout(100);
}
void 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);
});