Skip to content

Commit

Permalink
feat: allow to apply plugin asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Oct 9, 2019
1 parent ab90561 commit 0c0beb4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/saber/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Saber {

// Load built-in plugins
for (const plugin of builtinPlugins) {
this.applyPlugin(require(plugin.resolve), plugin.options)
await this.applyPlugin(require(plugin.resolve), plugin.options)
}

// Load user plugins
Expand All @@ -179,7 +179,7 @@ class Saber {
}

for (const plugin of userPlugins) {
this.applyPlugin(plugin, plugin.options, plugin.location)
await this.applyPlugin(plugin, plugin.options, plugin.location)
}

await this.hooks.afterPlugins.promise()
Expand Down Expand Up @@ -211,8 +211,9 @@ class Saber {
}
}

applyPlugin(plugin, options, pluginLocation) {
plugin.apply(this, options)
async applyPlugin(plugin, options, pluginLocation) {
await plugin.apply(this, options)

if (!plugin.name.startsWith('builtin:')) {
log.verbose(
() =>
Expand Down

0 comments on commit 0c0beb4

Please sign in to comment.