Skip to content

Commit 42d5c05

Browse files
committed
fixed incomplete output
1 parent 4005acc commit 42d5c05

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

bin/webpack.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,25 @@ webpack(options, function(err, stats) {
102102
return;
103103
}
104104
if(outputOptions.json)
105-
console.log(JSON.stringify(stats.toJson(outputOptions), null, 2));
105+
process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
106106
else {
107-
console.log(stats.toString(outputOptions));
107+
process.stdout.write(stats.toString(outputOptions) + "\n");
108108
}
109109
if(!options.watch) {
110110
// Do not keep cache anymore
111-
process.exit();
111+
// but wait until stdout has been written
112+
process.nextTick(function() {
113+
if(!process.stdout.write("")) {
114+
process.stdout.once("drain", function() {
115+
if(!process.stderr.write("")) {
116+
process.stderr.once("drain", function() {
117+
process.exit();
118+
});
119+
} else
120+
process.exit();
121+
});
122+
} else
123+
process.exit();
124+
});
112125
}
113126
});

0 commit comments

Comments
 (0)