Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function close (code) {
var i, len, closeHandler, closed = 0, opened = 0;

for (i = 0, len = children.length; i < len; i++) {
if (!children[i].exitCode) {
if (children[i].exitCode === null) {
opened++;
children[i].removeAllListeners('close');
if (process.platform != "win32") {
Expand Down
10 changes: 9 additions & 1 deletion test/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ else
# children
waitingProcess = (time=10000) ->
return "\"node -e 'setTimeout(function(){},#{time});'\""
waitingFailingProcess = (time=10000) ->
return "\"node -e 'setTimeout(function(){ throw new Error(); },#{time});'\""
failingProcess = "\"node -e 'throw new Error();'\""

usageInfo = """
Expand Down Expand Up @@ -86,6 +88,13 @@ describe "parallelshell", ->
ps.exitCode.should.equal 1
done()

it "should close with exitCode 1 on delayed child error", (done) ->
ps = spawnParallelshell([waitingFailingProcess(100),waitingProcess(1),waitingProcess(500)].join(" "))
spyOnPs ps, 2
ps.on "exit", () ->
ps.exitCode.should.equal 1
done()

it "should run with a normal child", (done) ->
ps = spawnParallelshell(waitingProcess())
spyOnPs ps, 1
Expand All @@ -96,7 +105,6 @@ describe "parallelshell", ->
killPs(ps)
),150


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