@gkalpak/cli-utils
Version:
A private collection of utilities for developing cli tools.
29 lines • 1.38 kB
TypeScript
export declare class ProcessUtils {
/**
* Run the specified `action`, when `exit` or `SIGINT` are fired on the specified process.
*
* @param proc - The process whose events to listen for.
* @param action - The callback to call on `exit` or `SIGINT`.
*
* @return A function to run for unregistering the listeners from `proc`.
*/
doOnExit(proc: NodeJS.Process, action: (codeOrSignal: number | NodeJS.Signals) => void): () => void;
/**
* Suppress the "Terminate batch job (Y/N)?" confirmation on Windows for the specified process.
* Calling this function with a non-Windows process is a no-op.
*
* Under the hood, it attaches a listener to `readline` interface and uses
* [taskkill](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/taskkill) to kill the
* process.
*
* NOTE: This is still an experimental feature and not guaranteed to work as expected.
* It is known to not work with certain types of commands (e.g. `vim`).
*
* @param proc - The process whose confirmation to suppress.
*
* @return A function to run for un-suppressing the confirmation.
*/
suppressTerminateBatchJobConfirmation(proc: NodeJS.Process): () => void;
}
export declare const processUtils: ProcessUtils;
//# sourceMappingURL=process-utils.d.ts.map