Skip to content

Commit b3bc42a

Browse files
committed
make shure IO streams are flushed before exiting a process.
wait for forked streams to end before resolving promise (cherry picked from commit 4539ccc) wait for io streams to end even when fork promise is rejected (cherry picked from commit 6bff82a)
1 parent c5d02f1 commit b3bc42a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cli.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var errors = [];
5151

5252
function error(err) {
5353
console.error(err.stack);
54-
process.exit(1);
54+
flushIoAndExit(1);
5555
}
5656

5757
function prefixTitle(file) {
@@ -167,13 +167,22 @@ function exit(results) {
167167
log.errors(flatten(tests));
168168
}
169169

170+
process.stdout.write('');
171+
172+
flushIoAndExit(
173+
failed > 0 || unhandledRejectionCount > 0 || uncaughtExceptionCount > 0 ? 1 : 0
174+
);
175+
}
176+
177+
function flushIoAndExit(code) {
170178
// TODO: figure out why this needs to be here to
171179
// correctly flush the output when multiple test files
172180
process.stdout.write('');
181+
process.stderr.write('');
173182

174-
// timeout required to correctly flush stderr on Node 0.10 Windows
183+
// timeout required to correctly flush io on Node 0.10 Windows
175184
setTimeout(function () {
176-
process.exit(failed > 0 || unhandledRejectionCount > 0 || uncaughtExceptionCount > 0 ? 1 : 0);
185+
process.exit(code);
177186
}, 0);
178187
}
179188

0 commit comments

Comments
 (0)