Skip to content

Return exit code 0 on delayed child process error #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2015
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