UNPKG

@intlayer/chokidar

Version:

Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.

47 lines (45 loc) 1.24 kB
import { spawn } from "node:child_process"; //#region src/utils/runParallel/spawnPosix.ts /** * Kills the new process and its sub processes synchronously using * process group kill (negative PID). This ensures all descendants * are terminated before the parent calls process.exit(). */ const createKillHandler = (child) => { return (signal) => { if (!child.pid) return false; const killSignal = signal ?? "SIGTERM"; try { process.kill(-child.pid, killSignal); return true; } catch {} try { process.kill(child.pid, killSignal); } catch {} return true; }; }; /** * Launches a new process with the given command. * This is almost same as `child_process.spawn`. * * This returns a `ChildProcess` instance. * `kill` method of the instance kills the new process and its sub processes. * * @param command - The command to run. * @param args - List of string arguments. * @param options - Options. * @returns A ChildProcess instance of new process. * @private */ const spawnPosix = (command, args, options) => { const child = spawn(command, args, { ...options, detached: true }); child.kill = createKillHandler(child); return child; }; //#endregion export { spawnPosix }; //# sourceMappingURL=spawnPosix.mjs.map