Skip to content

Commit 84a8419

Browse files
authored
fix: mock new hookable methods (#921)
1 parent 0f6ceec commit 84a8419

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/bridge/module.cjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ module.exports.defineNuxtConfig = (config = {}) => {
4040
}
4141
nuxtCtx.set(nuxt)
4242

43+
// Mock new hookable methods
44+
nuxt.removeHook ||= nuxt.clearHook.bind(nuxt)
45+
nuxt.removeAllHooks ||= nuxt.clearHooks.bind(nuxt)
46+
nuxt.hookOnce ||= (name, fn, ...hookArgs) => {
47+
const unsub = nuxt.hook(name, (...args) => {
48+
unsub()
49+
return fn(...args)
50+
}, ...hookArgs)
51+
return unsub
52+
}
53+
4354
// Mock _layers for nitro and auto-imports
4455
nuxt.options._layers = nuxt.options._layers || [{
4556
config: nuxt.options,

0 commit comments

Comments
 (0)