You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Justine Kate Catid Miras 5ef3abc3c3 | 1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago | |
index.js | 1 year ago | |
package.json | 1 year ago |
README.md
capture-exit
Allow cooprative async exit handlers, we unfortunately must hijack process.exit.
It allows a handler to ensure exit, without that exit handler impeding other similar handlers
for example, see: sindresorhus/ora#27
Differences between process.on('exit')
and captureExit.onExit(...)
=> https://github.com/ember-cli/capture-exit/issues/12
Installation
yarn add capture-exit
// or
npm install --save capture-exit
Usage
// as early in startup as possible
require('capture-exit').captureExit();
// when you want to schedule some work on exit:
function onExit() {
return something.processWillExit(); // you can return promises, which will pause exit until fulfilled
}
require('capture-exit').onExit(onExit); // add an exit handler
require('capture-exit').offExit(onExit); // allows one to remove an exit handle if it is not longer required