Skip to content

Commit 66974f9

Browse files
committed
fix: pass bsc-path arg only to specific subcommands
1 parent 18dddc3 commit 66974f9

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

cli/rewatch.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ import { rewatch_exe, bsc_exe } from "./common/bins.js";
77

88
const args = process.argv.slice(2);
99

10-
child_process.spawnSync(rewatch_exe, [...args, "--bsc-path", bsc_exe], {
11-
stdio: "inherit",
12-
});
10+
const firstPositionalArgIndex = args.findIndex((arg) => !arg.startsWith("-"));
11+
12+
try {
13+
if (firstPositionalArgIndex !== -1) {
14+
const subcommand = args[firstPositionalArgIndex];
15+
const subcommandArgs = args.slice(firstPositionalArgIndex + 1);
16+
17+
if (
18+
subcommand === "build" ||
19+
subcommand === "watch" ||
20+
subcommand === "clean" ||
21+
subcommand === "compiler-args"
22+
) {
23+
child_process.execFileSync(
24+
rewatch_exe,
25+
[...subcommandArgs, "--bsc-path", bsc_exe],
26+
{
27+
stdio: "inherit",
28+
}
29+
);
30+
} else {
31+
child_process.execFileSync(rewatch_exe, [...args], {
32+
stdio: "inherit",
33+
});
34+
}
35+
}
36+
} catch (err) {
37+
if (err.status !== undefined) {
38+
process.exit(err.status); // Pass through the exit code
39+
} else {
40+
process.exit(1); // Generic error
41+
}
42+
}

0 commit comments

Comments
 (0)