Skip to content

wait for forked streams to end before resolving promise #211

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

Closed
Closed
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
6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ environment:
install:
- ps: Install-Product node $env:nodejs_version
- set CI=true
- npm -g install npm@latest
- npm -g install npm@latest || (timeout 30 && npm -g install npm@latest)
- set PATH=%APPDATA%\npm;%PATH%
- npm install
- npm install || (timeout 30 && npm install)
matrix:
fast_finish: true
build: off
Expand All @@ -19,4 +19,4 @@ clone_depth: 1
test_script:
- node --version
- npm --version
- npm run test-win
- npm run test-win || (timeout 30 && npm run test-win)
4 changes: 3 additions & 1 deletion lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ if (!avaRequired) {

process.on('message', function (message) {
if (message['ava-kill-command']) {
process.exit(0);
setTimeout(function () {
process.exit(0);
}, 10);
}
});
18 changes: 15 additions & 3 deletions lib/fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,23 @@ module.exports = function (args) {
ps.emit('data', data);
});

promise.on = function () {
ps.on.apply(ps, arguments);
var stdout = new Promise(function (resolve) {
ps.stdout.on('end', resolve);
});

var stderr = new Promise(function (resolve) {
ps.stderr.on('end', resolve);
});

var endPromise = Promise.all([promise.reflect(), stdout, stderr]).then(function () {
return promise;
});

endPromise.on = function () {
ps.on.apply(ps, arguments);

return endPromise;
};

return promise;
return endPromise;
};