exit-hook-plus
Version:
Do something before the program exits or when the program crashes!
29 lines (28 loc) • 922 B
TypeScript
export declare type ExitReason =
| ExitReasonTrivial
| ExitReasonException
| ExitReasonSignal
| ExitReasonManual;
export declare type ExitReasonTrivial = {
category: 'trivial';
exitCode: number;
};
export declare type ExitReasonException = {
category: 'exception';
errorOrReason?: Error | any;
};
export declare type ExitReasonSignal = {
category: 'signal';
signal: 'SIGHUP' | 'SIGINT' | 'SIGTERM' | 'SIGBREAK';
};
export declare type ExitReasonManual = {
category: 'manual';
extra?: any;
};
export declare type ExitHook = {
_executed?: boolean;
} & (((reason: ExitReason) => Promise<void>) | ((reason: ExitReason) => void));
export declare function disableDefaultExitLogger(): void;
export declare function addExitHook(hook: ExitHook): void;
export declare function removeExitHook(hook: ExitHook): void;
export declare function executeAllHooksAndTerminate(exitCode?: number, extra?: any): void;