alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
31 lines (29 loc) • 731 B
JavaScript
import "../../chunks/chunk-U5RRZUYZ.js";
// src/cli/util/ForwardCommand.ts
import { spawn } from "child_process";
function forwardCommand(env = {}) {
const argv = process.argv;
const separator = argv.findIndex((arg) => arg === "--");
if (separator === -1)
return;
const command = argv.slice(separator + 1);
if (command.length === 0)
return;
function finish(code) {
process.exit(code);
}
const instance = spawn(command.join(" "), {
shell: true,
stdio: "inherit",
env: {
...process.env,
...env
}
});
instance.on("exit", finish);
process.on("SIGINT", () => instance.kill("SIGINT"));
process.on("SIGTERM", () => instance.kill("SIGTERM"));
}
export {
forwardCommand
};