|
|
il y a 2 semaines | |
|---|---|---|
| .. | ||
| index.js | il y a 2 semaines | |
| package.json | il y a 2 semaines | |
| readme.md | il y a 2 semaines | |
Run some code when the process exits
The process.on('exit') event doesn't catch all the ways a process can exit.
Useful for cleaning up.
$ npm install --save exit-hook
var exitHook = require('exit-hook');
exitHook(function () {
console.log('exiting');
});
// you can add multiple hooks, even across files
exitHook(function () {
console.log('exiting 2');
});
throw new Error('unicorns');
//=> exiting
//=> exiting 2
MIT © Sindre Sorhus