(target)
| 8 | const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"] |
| 9 | |
| 10 | function run(target) { |
| 11 | const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit" }) |
| 12 | child.on("error", (error) => { |
| 13 | console.error(error.message) |
| 14 | process.exit(1) |
| 15 | }) |
| 16 | const forwarders = {} |
| 17 | for (const signal of forwardedSignals) { |
| 18 | forwarders[signal] = () => { |
| 19 | try { |
| 20 | child.kill(signal) |
| 21 | } catch {} |
| 22 | } |
| 23 | process.on(signal, forwarders[signal]) |
| 24 | } |
| 25 | child.on("exit", (code, signal) => { |
| 26 | for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal]) |
| 27 | if (signal) return process.kill(process.pid, signal) |
| 28 | process.exit(typeof code === "number" ? code : 0) |
| 29 | }) |
| 30 | } |
| 31 | |
| 32 | const envPath = process.env.OPENCODE_BIN_PATH |
| 33 | const scriptDir = path.dirname(fs.realpathSync(__filename)) |
no test coverage detected