Skip to content

Commit 7db1fb6

Browse files
author
Nicholas C. Zakas
committed
Workaround for Node.js stdout not flushing prior to exit (fixes #176)
1 parent 39e20ba commit 7db1fb6

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

csslint.txt

Lines changed: 3 additions & 0 deletions
Large diffs are not rendered by default.

src/cli/node.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ cli({
1111

1212
print: function(message){
1313
fs.writeSync(1, message + "\n");
14-
fs.fsyncSync(1);
1514
},
1615

1716
quit: function(code){
18-
process.exit(code || 0);
17+
18+
//Workaround for https://github.com/joyent/node/issues/1669
19+
var flushed = process.stdout.flush()
20+
if (!flushed) {
21+
process.once("drain", function () {
22+
process.exit(code || 0)
23+
});
24+
} else {
25+
process.exit(code || 0);
26+
}
1927
},
2028

2129
isDirectory: function(name){
@@ -63,3 +71,4 @@ cli({
6371
return fs.readFileSync(filename, "utf-8");
6472
}
6573
});
74+

0 commit comments

Comments
 (0)