@intlayer/chokidar
Version:
Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.
49 lines (47 loc) • 1.43 kB
JavaScript
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
let node_child_process = require("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 = (0, node_child_process.spawn)(command, args, {
...options,
detached: true
});
child.kill = createKillHandler(child);
return child;
};
//#endregion
exports.spawnPosix = spawnPosix;
//# sourceMappingURL=spawnPosix.cjs.map