1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 | import { platform } from "os";
|
5 | import { spawn } from "child_process";
|
6 | import { join } from "path";
|
7 |
|
8 | let argv = process.argv.slice(2);
|
9 |
|
10 | if (platform() === "win32") {
|
11 | argv = [join(__dirname, "busybox.exe"), ...argv];
|
12 | }
|
13 |
|
14 | var child = spawn(argv[0], argv.slice(1), {
|
15 | stdio: "inherit",
|
16 | });
|
17 | child.on("close", code => {
|
18 | process.exit(code);
|
19 | });
|
20 |
|
21 | ["SIGINT", "SIGTERM"].map(signal => {
|
22 | process.on(signal, () => {
|
23 | if (!child.killed) {
|
24 | child.kill(signal);
|
25 | }
|
26 | });
|
27 | });
|