-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch.js
More file actions
29 lines (24 loc) · 793 Bytes
/
watch.js
File metadata and controls
29 lines (24 loc) · 793 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
27
28
29
// @ts-check
// Do not run this file directly, Run it via `npm run watch`. See package.json for more info.
const { spawn } = require("child_process");
/**
*
* @param {string} program
* @param {string[]} args
* @returns {ReturnType<typeof spawn>}
*/
function cmd(program, args) {
const spawnOptions = { "shell": true };
console.log(`CMD:${program} ${args.flat()} ${spawnOptions}`)
const p = spawn(program, args.flat(), spawnOptions);
p.stdout.on("data", (data) => process.stdout.write(data));
p.stderr.on("data", (data) => process.stdout.write(data));
p.on("close", (code) => {
if (code != 0) {
console.error(program, args, "exited with", code);
}
});
return p;
}
cmd("tsc", ["-w"]);
cmd("http-server", ["-p", "6969", "-a", "0.0.0.0", "-s", "-c-1"]);