123456789101112131415 |
- module.exports = function (fn) {
- const cleanup = () => {
- try {
- fn()
- } finally {
- process.exit()
- }
- }
- process.on('exit', cleanup)
- process.on('SIGINT', cleanup)
- process.on('SIGTERM', cleanup)
- process.on('SIGHUP', cleanup)
- process.on('SIGBREAK', cleanup)
- }
|