Skip to content

Commit 27cf758

Browse files
Slashgearkefranabg
authored andcommitted
feat(options): make enhancers async ready
1 parent 74017c5 commit 27cf758

File tree

1 file changed

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

1 file changed

+9
-9
lines changed

packages/@vuepress/core/lib/node/Page.js

Lines changed: 9 additions & 9 deletions
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

@@ -283,13 +283,13 @@ module.exports = class Page {
283283
*/
284284

285285
enhance (enhancers) {
286-
for (const { name: pluginName, value: enhancer } of enhancers) {
287-
try {
288-
enhancer(this)
289-
} catch (error) {
290-
console.log(error)
291-
throw new Error(`[${pluginName}] excuete extendPageData failed.`)
292-
}
293-
}
286+
return enhancers.reduce(async (accumulator, { pluginName, value }) => {
287+
return accumulator
288+
.then(() => value(this))
289+
.catch(error => {
290+
console.log(error)
291+
throw new Error(`[${pluginName}] execute extendPageData failed.`)
292+
})
293+
}, Promise.resolve())
294294
}
295295
}

0 commit comments

Comments
 (0)