DefinitelyTyped/types/node-cleanup/node-cleanup-tests.ts
Jakub Jirutka c2426c074c node-cleanup: Allow handler returning void (#37743)
node-cleanup accepts even handlers that doesn't return anything.
2019-08-26 08:29:27 -07:00

18 lines
514 B
TypeScript

import nodeCleanup = require('node-cleanup');
function cleanupHandler(exitCode: number | null, signal: string | null): boolean | undefined {
return true;
}
function voidHandler(): void {
// do nothing
}
const stderrMessages = { ctrl_C: 'ctrl_c', uncaughtException: 'UncaughtException' };
nodeCleanup();
nodeCleanup(cleanupHandler);
nodeCleanup(cleanupHandler, undefined);
nodeCleanup(cleanupHandler, stderrMessages);
nodeCleanup(voidHandler);
nodeCleanup(undefined, stderrMessages);
nodeCleanup.uninstall();