Skip to content

Commit

Permalink
Fix the way promises are handled here.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Panike committed Dec 16, 2019
1 parent 8dc1ba9 commit 71cebfa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/auto-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ const Prefix = require('./prefix');
module.exports.getFiles = (baseDir, pattern) => {

if (Array.isArray(baseDir)) {
const files = baseDir.map(async (d) => await this.getFiles(d, pattern));
return Promise.resolve(files);
const promise = new Promise((resolve, reject) => {
Promise.all(baseDir.map((d) => this.getFiles(d, pattern)))
.then((value) => resolve(Hoek.flatten(value)))
.catch((reason) => reject(reason));
})
return promise;
}

const absolutePattern = Path.join(baseDir, pattern);
Expand Down

0 comments on commit 71cebfa

Please sign in to comment.