Comparing version 1.0.1 to 1.0.2
19
index.js
@@ -10,3 +10,4 @@ if (process.version.match(/^v(0\.12\.|[^0])/)) | ||
code = c | ||
setup() | ||
if (exiting && code) | ||
process.exit(code) | ||
}, | ||
@@ -19,11 +20,7 @@ get: function () { | ||
var didSetup = false | ||
function setup () { | ||
if (didSetup) | ||
return | ||
didSetup = true | ||
process.on('exit', function (c) { | ||
if (code && !c) | ||
process.exit(code) | ||
}) | ||
} | ||
var exiting = false | ||
process.on('exit', function (c) { | ||
exiting = true | ||
if (code && !c) | ||
process.exit(code) | ||
}) |
{ | ||
"name": "exit-code", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "`process.exitCode` behavior back-ported from io.js and Node.js 0.12+", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
23
test.js
@@ -10,2 +10,12 @@ if (!isNaN(process.argv[2])) { | ||
if (!isNaN(process.argv[3])) { | ||
require('./') | ||
setTimeout(function () { | ||
process.on('exit', function () { | ||
process.exitCode = +process.argv[3] | ||
}) | ||
}) | ||
return | ||
} | ||
var test = require('tap').test | ||
@@ -16,9 +26,18 @@ var spawn = require('child_process').spawn | ||
test('exitCodes', function (t) { | ||
test('immediate exit', function (t) { | ||
t.plan(codes.length) | ||
codes.forEach(function (want) { | ||
spawn(node, [__filename, want]).on('close', function (found) { | ||
t.equal(found, want) | ||
t.equal(found, want, 'immediate exit ' + want) | ||
}) | ||
}) | ||
}) | ||
test('deferred exit', function (t) { | ||
t.plan(codes.length) | ||
codes.forEach(function (want) { | ||
spawn(node, [__filename, 'x', want]).on('close', function (found) { | ||
t.equal(found, want, 'deferred exit ' + want) | ||
}) | ||
}) | ||
}) |
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
2937
59