Skip to content

Commit

Permalink
fix: add compatibility with hable (#1025)
Browse files Browse the repository at this point in the history
  • Loading branch information
wattanx authored Dec 21, 2023
1 parent 49c4c2d commit 1fa3dce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/bridge/module.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ module.exports.defineNuxtConfig = (config = {}) => {
nuxt.removeAllHooks ||= nuxt.clearHooks.bind(nuxt)
nuxt.hookOnce ||= (name, fn, ...hookArgs) => {
const unsub = nuxt.hook(name, (...args) => {
unsub()
if (typeof unsub === 'function') {
unsub()
} else {
// In hable@^3.0.0, the hook does not return a function.
nuxt.removeHook(name, fn)
}

return fn(...args)
}, ...hookArgs)
return unsub
Expand Down

0 comments on commit 1fa3dce

Please sign in to comment.