Skip to content

Commit 5b3e53b

Browse files
authored
Merge pull request #66 from straker/readFileGlobOrder
fix(utils): fix bug that read files out of order
2 parents 9b0fd27 + 67eaab3 commit 5b3e53b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/utils.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,17 @@ utils.readFileGlobs = function readFileGlobs(patterns, callback) {
139139
promises.length = 0;
140140

141141
fileList.forEach(function(files) {
142-
promises.push(utils.readFiles(files, callback));
142+
promises.push(new Promise(function(resolve, reject) {
143+
utils.readFiles(files, function(data, file) {
144+
resolve([data, file]);
145+
});
146+
}));
143147
});
144148

145-
Promise.all(promises).then(function() {
149+
Promise.all(promises).then(function(files) {
150+
files.forEach(function(data) {
151+
callback.apply(null, data);
152+
});
146153
resolve();
147154
})
148155
.catch(function(err) {

0 commit comments

Comments
 (0)