Skip to content

Commit a044ea6

Browse files
committed
Merge pull request #37 from sublimino/dev
Return exit code 0 on delayed child process error
2 parents 507552f + 6d26a35 commit a044ea6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function close (code) {
7676
var i, len, closeHandler, closed = 0, opened = 0;
7777

7878
for (i = 0, len = children.length; i < len; i++) {
79-
if (!children[i].exitCode) {
79+
if (children[i].exitCode === null) {
8080
opened++;
8181
children[i].removeAllListeners('close');
8282
if (process.platform != "win32") {

test/index.coffee

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ else
1616
# children
1717
waitingProcess = (time=10000) ->
1818
return "\"node -e 'setTimeout(function(){},#{time});'\""
19+
waitingFailingProcess = (time=10000) ->
20+
return "\"node -e 'setTimeout(function(){ throw new Error(); },#{time});'\""
1921
failingProcess = "\"node -e 'throw new Error();'\""
2022

2123
usageInfo = """
@@ -86,6 +88,13 @@ describe "parallelshell", ->
8688
ps.exitCode.should.equal 1
8789
done()
8890

91+
it "should close with exitCode 1 on delayed child error", (done) ->
92+
ps = spawnParallelshell([waitingFailingProcess(100),waitingProcess(1),waitingProcess(500)].join(" "))
93+
spyOnPs ps, 2
94+
ps.on "exit", () ->
95+
ps.exitCode.should.equal 1
96+
done()
97+
8998
it "should run with a normal child", (done) ->
9099
ps = spawnParallelshell(waitingProcess())
91100
spyOnPs ps, 1
@@ -96,7 +105,6 @@ describe "parallelshell", ->
96105
killPs(ps)
97106
),150
98107

99-
100108
it "should close sibling processes on child error", (done) ->
101109
ps = spawnParallelshell([waitingProcess(),failingProcess].join(" "))
102110
spyOnPs ps,2

0 commit comments

Comments
 (0)