Run some code when the process exits
process.on('exit') event doesn't catch all the ways a process can exit.
This package is useful for cleaning up before exiting.
async-exit-hook if you need async support.
$ npm install exit-hook
const exitHook = ;;// You can add multiple hooks, even across files;throw '🦄';//=> 'Exiting'//=> 'Exiting 2'
Removing an exit hook:
const exitHook = ;const unsubscribe = ;;
Returns a function that removes the hook when called.
The callback to execute when the process exits.
MIT © Sindre Sorhus