Node.js program finisher - run your last callback with `exit code` and `signal name` as arguments
npm install finisRun your callback before node exit, pass exit code and signal name as arguments
``shell`
npm install finis --save
finis() installs a callback function which will be run just before the node process exits.
The callback function will be called when:
1. the process exits normally
1. the user presses _Ctrl+C_
1. an exception is uncaught
`js
const finis = require('finis')
finis((code, signal, error) => {
console.log(finis(${code}, ${signal}, ${error}))`
})
`ts
import finis from 'finis'
finis((code: number, signal: 'exit'|'SIGINT'|'SIGTERM'|'uncaughtException', error?: Error) => {
console.log(finis(${code}, ${signal}, ${error}))`
})
You may call finis() multiple times to install multiple callback functions.
1. Do not call process.exit by defaultSIGTERM`
1. Add support to
1. Add support to TypeScript
This module is inspired by @jtlapp/node-cleanup, which is borrowed and modified from CanyonCasa's answer to a stackoverflow question. I found the code necessary for all my node projects. See the stackoverflow answer for more examples of use.
Huan LI \
* Code & Docs © 2016-2017 Huan LI \
* Code released under the Apache-2.0 License
* Docs released under Creative Commons