Kit
Lifecycle hooks
Every kubb:* hook a build fires, its payload, and when it fires. Listen with kubb.hooks.hook(name, handler) or from a plugin's hooks map.
Kubb runs on one shared, typed hook emitter, and every phase of a build fires a kubb:* hook on it. Plugins listen through their hooks map. Outside code listens through kubb.hooks.
Every hook name and its payload lives in the KubbHooks type. Handlers can be async, and Kubb awaits each one.
Listening
Attach a listener with kubb.hooks.hook(name, handler) before you call build().
import { createKubb } from 'kubb'
const kubb = createKubb({
input: './petStore.yaml',
output: { path: './gen' },
})
kubb.hooks.hook('kubb:plugin:end', ({ plugin, duration }) => {
console.log(`${plugin.name} finished in ${duration}ms`)
})
kubb.hooks.hook('kubb:build:end', ({ files }) => {
console.log(`Generated ${files.length} files`)
})
await kubb.build()
Firing order
A full generation run fires the hooks in this order.