Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit e8ca9ed

Browse files
be very explicit about exiting process and clearing timeout
1 parent ecdad2a commit e8ca9ed

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

bin/codecov

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,24 @@ var args = argv.option([
2323

2424
// listen for piped input for 500ms
2525
var listeningTime = 500;
26+
var readingPiped = false;
2627
process.stdin.setEncoding('utf8');
27-
process.stdin.on('data', function(report) {
28-
if (report !== null) {
28+
process.stdin.on('readable', function() {
29+
var data = process.stdin.read();
30+
if (data !== null) {
31+
readingPiped = true;
2932
clearTimeout(timer);
3033
if (!args.options.pipe) args.options.pipe = [];
31-
args.options.pipe.push(report);
34+
args.options.pipe.push(data);
3235
}
3336
});
3437
process.stdin.on('end', function() {
35-
codecov.upload(args);
38+
if (readingPiped) codecov.upload(args);
3639
});
3740

38-
var timer = setTimeout(codecov.upload, listeningTime, args)
41+
var timer = setTimeout(function() {
42+
if (!readingPiped) {
43+
codecov.upload(args);
44+
process.exit();
45+
}
46+
}, listeningTime);

0 commit comments

Comments
 (0)