Socket
Socket
Sign inDemoInstall

exit-hook

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exit-hook - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

29

index.js
'use strict';
module.exports = function (cb) {
var exit = function (sig) {
cb();
if (sig) {
process.exit(128);
}
};
var cbs = [];
process.once('exit', exit);
process.once('SIGINT', exit.bind(null, true));
process.once('SIGTERM', exit.bind(null, true));
function exit(sig) {
cbs.forEach(function (el) {
el();
});
if (sig) {
process.exit(128);
}
};
module.exports = function (cb) {
cbs.push(cb);
if (cbs.length === 1) {
process.once('exit', exit);
process.once('SIGINT', exit.bind(null, true));
process.once('SIGTERM', exit.bind(null, true));
}
};
{
"name": "exit-hook",
"version": "1.0.0",
"version": "1.1.0",
"description": "Run some code when the process exits",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -26,5 +26,11 @@ # exit-hook [![Build Status](https://travis-ci.org/sindresorhus/exit-hook.svg?branch=master)](https://travis-ci.org/sindresorhus/exit-hook)

// you can add multiple hooks, even across files
exitHook(function () {
console.log('exiting 2');
});
throw new Error('unicorns');
//=> exiting
//=> exiting 2
```

@@ -31,0 +37,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc