histoire
Version:
A fast story book powered by Vite
30 lines • 1.34 kB
TypeScript
/** Minimal writable-stream shape used to flush the CLI output. */
interface FlushableStream {
write: (chunk: string, callback: () => void) => unknown;
}
export interface ExitAfterFlushOptions {
/** Exit code. Defaults to the current `process.exitCode`. */
code?: number;
/** Time to wait for a natural exit (and for each flush) before forcing one. */
graceMs?: number;
/** Streams to flush. Defaults to stdout and stderr. */
streams?: FlushableStream[];
/** Injected for tests. */
exit?: (code: number) => void;
/** Injected for tests. */
warn?: (message: string) => void;
}
/**
* Ends the CLI without truncating its output.
*
* `process.exit()` discards whatever is still buffered for a piped stdout (CI
* logs, `| tee`), so the report is flushed first and the process is then left
* to exit naturally. Leaked handles (a Playwright browser whose cleanup timed
* out, a Vite server, ws connections) would keep the event loop alive forever,
* so an unref'd timer force-exits as a last resort — unref'd precisely so a
* healthy process still exits as soon as its work is done.
* @param options Exit configuration (see {@link ExitAfterFlushOptions}).
*/
export declare function exitAfterFlush(options?: ExitAfterFlushOptions): Promise<void>;
export {};
//# sourceMappingURL=exit.d.ts.map