UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

31 lines (29 loc) 731 B
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 };