Skip to content

fix for #12 #14

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 2 commits into from
May 5, 2015
Merged

fix for #12 #14

merged 2 commits into from
May 5, 2015

Conversation

paulpflug
Copy link
Collaborator

changed alot. pls review!
#12

if (verbose) console.log('`' + children[i].cmd + '` will now be closed');
}
}
process.exit();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a breaking change here. Before, parallelshell would exit with a non-zero exit code if the child process did, now it does not. This close function should ideally find the first non-zero exit code and exit with that (or if all exit codes are 0, of course, then exit with that).

Simply refactor this function as follows:

function close () {
    var code = 0;
    for (var i = 0, len = children.length; i < len; i++) {
        if (!children[i].exitCode) {
            children[i].removeAllListeners('close');
            children[i].kill('SIGINT');
            if (verbose) console.log('`' + children[i].cmd + '` will now be closed');
        } else {
            code = children[i].exitCode;
        }
    }
    process.exit(code);
}

@keithamus
Copy link
Collaborator

Great work @paulpflug! I've made a couple of comments above that I'd like to see addressed, then I'm happy to merge 😄

@paulpflug
Copy link
Collaborator Author

I did work it in + added a proper unit test

@keithamus
Copy link
Collaborator

Nice work 😄

keithamus added a commit that referenced this pull request May 5, 2015
@keithamus keithamus merged commit dd5bd33 into darkguy2008:master May 5, 2015
estk pushed a commit to estk/parallelshell that referenced this pull request Sep 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants