capture-exit
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -60,2 +60,5 @@ var RSVP = require('rsvp'); | ||
module.exports.onExit = function(cb) { | ||
if (!exit) { | ||
throw new Error('Cannot install handler when exit is not captured. Call `captureExit()` first'); | ||
} | ||
var index = handlers.indexOf(cb); | ||
@@ -62,0 +65,0 @@ |
{ | ||
"name": "capture-exit", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "safely cleanup in signal handlers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13
test.js
@@ -9,2 +9,3 @@ var expect = require('chai').expect; | ||
beforeEach(function() { | ||
exit.releaseExit(); | ||
expect(process.exit, 'ensure we start in a correct state').to.equal(originalExit); | ||
@@ -124,2 +125,3 @@ }); | ||
it('subscribes', function() { | ||
exit.captureExit(); | ||
var didExit = 0; | ||
@@ -140,2 +142,3 @@ function foo() { | ||
it('does not subscribe duplicates', function() { | ||
exit.captureExit(); | ||
var didExit = 0; | ||
@@ -155,2 +158,8 @@ function foo() { | ||
}); | ||
it('throws if exit is not captured', function() { | ||
expect(function () { | ||
exit.onExit(function () { }); | ||
}).to.throw('Cannot install handler when exit is not captured. Call `captureExit()` first'); | ||
}); | ||
}); | ||
@@ -160,2 +169,4 @@ | ||
it('unsubscribes', function() { | ||
exit.captureExit(); | ||
var didExit = 0; | ||
@@ -180,2 +191,4 @@ var didExitBar = 0; | ||
it('does not unsubscribe duplicates', function() { | ||
exit.captureExit(); | ||
var didExit = 0; | ||
@@ -182,0 +195,0 @@ var didExitBar = 0; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10783
269