Skip to content

Commit d117461

Browse files
committed
feat(options): make enhancers async ready
1 parent 23b0ce3 commit d117461

File tree

1 file changed

+9
-9
lines changed
  • packages/@vuepress/core/lib/node

1 file changed

+9
-9
lines changed

Diff for: packages/@vuepress/core/lib/node/Page.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module.exports = class Page {
142142
this._computed = computed
143143
this._localePath = computed.$localePath
144144

145-
this.enhance(enhancers)
145+
await this.enhance(enhancers)
146146
this.buildPermalink()
147147
}
148148

@@ -245,13 +245,13 @@ module.exports = class Page {
245245
*/
246246

247247
enhance (enhancers) {
248-
for (const { name: pluginName, value: enhancer } of enhancers) {
249-
try {
250-
enhancer(this)
251-
} catch (error) {
252-
console.log(error)
253-
throw new Error(`[${pluginName}] excuete extendPageData failed.`)
254-
}
255-
}
248+
return enhancers.reduce(async (accumulator, { pluginName, value }) => {
249+
return accumulator
250+
.then(() => value(this))
251+
.catch(error => {
252+
console.log(error)
253+
throw new Error(`[${pluginName}] execute extendPageData failed.`)
254+
})
255+
}, Promise.resolve())
256256
}
257257
}

0 commit comments

Comments
 (0)