st-bundle
Version:
CLI for watching and bundling SpringType projects.
21 lines (20 loc) • 661 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const handlers = {};
function onExit(name, exitHandler) {
handlers[name] = exitHandler;
}
exports.onExit = onExit;
function globalExitHandler(type) {
for (const key in handlers) {
handlers[key](type);
}
if (type === 'exit') {
process.exit();
}
}
process.on('exit', () => globalExitHandler('cleanup'));
process.on('SIGINT', () => globalExitHandler('exit'));
process.on('SIGUSR1', () => globalExitHandler('exit'));
process.on('SIGUSR2', () => globalExitHandler('exit'));
process.on('uncaughtException', () => globalExitHandler('uncaughtException'));