UNPKG

536 BJavaScriptView Raw
1#!/usr/bin/env node
2// SPDX-License-Identifier: Unlicense
3
4import { platform } from "os";
5import { spawn } from "child_process";
6import { join } from "path";
7
8let argv = process.argv.slice(2);
9
10if (platform() === "win32") {
11 argv = [join(__dirname, "busybox.exe"), ...argv];
12}
13
14var child = spawn(argv[0], argv.slice(1), {
15 stdio: "inherit",
16});
17child.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});