-
Notifications
You must be signed in to change notification settings - Fork 482
Expand file tree
/
Copy pathrewatch.js
More file actions
executable file
·47 lines (41 loc) · 1.17 KB
/
rewatch.js
File metadata and controls
executable file
·47 lines (41 loc) · 1.17 KB
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
47
#!/usr/bin/env node
// @ts-check
import * as child_process from "node:child_process";
import { rewatch_exe, bsc_exe } from "./common/bins.js";
const args = process.argv.slice(2);
const firstPositionalArgIndex = args.findIndex((arg) => !arg.startsWith("-"));
try {
if (firstPositionalArgIndex !== -1) {
const subcommand = args[firstPositionalArgIndex];
const subcommandWithArgs = args.slice(firstPositionalArgIndex);
if (
subcommand === "build" ||
subcommand === "watch" ||
subcommand === "clean" ||
subcommand === "compiler-args"
) {
child_process.execFileSync(
rewatch_exe,
[...subcommandWithArgs, "--bsc-path", bsc_exe],
{
stdio: "inherit",
}
);
} else {
child_process.execFileSync(rewatch_exe, [...args], {
stdio: "inherit",
});
}
} else {
// no subcommand means build subcommand
child_process.execFileSync(rewatch_exe, [...args, "--bsc-path", bsc_exe], {
stdio: "inherit",
});
}
} catch (err) {
if (err.status !== undefined) {
process.exit(err.status); // Pass through the exit code
} else {
process.exit(1); // Generic error
}
}