[modules] Support promise

This commit is contained in:
Pooya Parsa 2017-05-11 23:34:50 +04:30
parent 336ebd4959
commit b701424aae
1 changed files with 4 additions and 1 deletions

View File

@ -99,12 +99,15 @@ class Module {
}
// Call module with `this` context and pass options
return new Promise((resolve, reject) => {
return module.call(this, options, err => {
const result = module.call(this, options, err => {
if (err) {
return reject(err)
}
resolve(module)
})
if (result && result.then instanceof Function) {
return result.then(resolve)
}
})
}
}