Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 3da4503

Browse files
ChadKillingsworthDominator008
authored andcommitted
Wait for the 'end' event on stderr and stdout before writing out the messages (#30)
1 parent c447f84 commit 3da4503

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

lib/gulp/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,28 @@ module.exports = function(initOptions) {
131131
compilerProcess.stderr.on('data', function (data) {
132132
stdErrData += data;
133133
});
134-
compilerProcess.on('close', (function (code) {
134+
135+
Promise.all([
136+
new Promise(function(resolve) {
137+
compilerProcess.on('close', function(code) {
138+
resolve(code);
139+
});
140+
}),
141+
new Promise(function(resolve) {
142+
compilerProcess.stdout.on('end', function() {
143+
resolve();
144+
});
145+
}),
146+
new Promise(function(resolve) {
147+
compilerProcess.stderr.on('end', function() {
148+
resolve();
149+
});
150+
})
151+
]).then((function(results) {
152+
var code = results[0];
135153
// non-zero exit means a compilation error
136154
if (code !== 0) {
137-
this.emit('error', new PluginError(this.PLUGIN_NAME_,
138-
'Compilation error: \n\n' + compiler.prependFullCommand(stdErrData)));
155+
this.emit('error', new PluginError(this.PLUGIN_NAME_, 'Compilation error'));
139156
}
140157

141158
// standard error will contain compilation warnings, log those

test/gulp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('gulp-google-closure-compiler', function() {
5353
});
5454

5555
stream.on('error', function (err) {
56-
err.message.should.startWith('Compilation error:');
56+
err.message.should.startWith('Compilation error');
5757
done();
5858
});
5959
stream.write(fakeFile1);

0 commit comments

Comments
 (0)