refactor: simplify return value in addModule (#4766)

This commit is contained in:
Xin Du (Clark) 2019-01-16 17:50:45 +00:00 committed by Pooya Parsa
parent 381e0af52f
commit 9c9d519576

View File

@ -111,7 +111,7 @@ export default class ModuleContainer {
return this.addModule(moduleOpts, true /* require once */) return this.addModule(moduleOpts, true /* require once */)
} }
addModule(moduleOpts, requireOnce) { async addModule(moduleOpts, requireOnce) {
let src let src
let options let options
let handler let handler
@ -157,17 +157,7 @@ export default class ModuleContainer {
options = {} options = {}
} }
return new Promise((resolve) => { const result = await handler.call(this, options)
// Call module with `this` context and pass options return result
const result = handler.call(this, options)
// If module send back a promise
if (result && result.then) {
return resolve(result)
}
// synchronous
return resolve()
})
} }
} }