Skip to content

Commit 52cf8a1

Browse files
committed
consistent order in MultiCompiler
1 parent 592340c commit 52cf8a1

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/MultiCompiler.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ function runWithDependencies(compilers, fn, callback) {
128128

129129
MultiCompiler.prototype.watch = function(watchOptions, handler) {
130130
var watchings = [];
131-
var allStats = [];
131+
var allStats = this.compilers.map(function() {
132+
return null;
133+
});
132134
var compilerStatus = this.compilers.map(function() {
133135
return false;
134136
});
@@ -140,11 +142,10 @@ MultiCompiler.prototype.watch = function(watchOptions, handler) {
140142
if(err)
141143
handler(err);
142144
if(stats) {
143-
allStats.push(stats);
145+
allStats[compilerIdx] = stats;
144146
compilerStatus[compilerIdx] = true;
145147
if(compilerStatus.every(Boolean)) {
146148
var multiStats = new MultiStats(allStats);
147-
allStats = [];
148149
handler(null, multiStats)
149150
}
150151
}
@@ -162,15 +163,18 @@ MultiCompiler.prototype.watch = function(watchOptions, handler) {
162163
};
163164

164165
MultiCompiler.prototype.run = function(callback) {
165-
var allStats = [];
166+
var allStats = this.compilers.map(function() {
167+
return null;
168+
});
166169

167170
runWithDependencies(this.compilers, function(compiler, callback) {
171+
var compilerIdx = this.compilers.indexOf(compiler);
168172
compiler.run(function(err, stats) {
169173
if(err) return callback(err);
170-
allStats.push(stats);
174+
allStats[compilerIdx] = stats;
171175
callback();
172176
});
173-
}, function(err) {
177+
}.bind(this), function(err) {
174178
if(err) return callback(err);
175179
callback(null, new MultiStats(allStats));
176180
});

0 commit comments

Comments
 (0)