diff --git a/examples/node-api/node-script.js b/examples/node-api/node-script.js index 8318b24438..28a672453a 100644 --- a/examples/node-api/node-script.js +++ b/examples/node-api/node-script.js @@ -18,11 +18,6 @@ const bud = await factory() */ bud.setPath(`@dist`, `dist/build-a`) -/** - * Add extensions - */ -await bud.extensions.add([`@roots/bud-swc`]) - /** * Run build */ diff --git a/sources/@roots/bud-framework/src/methods/after/index.ts b/sources/@roots/bud-framework/src/methods/after/index.ts index d67beab296..a9b30b2009 100644 --- a/sources/@roots/bud-framework/src/methods/after/index.ts +++ b/sources/@roots/bud-framework/src/methods/after/index.ts @@ -15,8 +15,15 @@ export const after: after = function ( fn: ((app: Bud) => any) | ((app: Bud) => Promise), onError?: (error: Error) => unknown, ): Bud { + const handleError = onError ?? this.catch + this.hooks.action(`compiler.done`, async bud => { - await fn(bud).catch(onError ?? bud.catch) + try { + await bud.resolvePromises() + await fn(bud) + } catch (error) { + handleError(error) + } }) return this diff --git a/sources/@roots/bud-hooks/src/event/event.ts b/sources/@roots/bud-hooks/src/event/event.ts index 9e0cff132c..e94ea1a331 100644 --- a/sources/@roots/bud-hooks/src/event/event.ts +++ b/sources/@roots/bud-hooks/src/event/event.ts @@ -7,10 +7,7 @@ import {BudError} from '@roots/bud-support/errors' import {Hooks} from '../base/base.js' /** - * Synchronous hooks registry - * - * @remarks - * Supports sync values + * Event hooks */ export class EventHooks extends Hooks { @bind @@ -22,12 +19,13 @@ export class EventHooks extends Hooks { for await (const action of this.store[id] as any) { this.logger.info(`running ${id}`) + try { await action(...value) await this.app.resolvePromises() } catch (error) { - this.logger.error(`problem running ${id} callback`) - throw BudError.normalize(error) + this.logger.error(`problem running ${id} callback`, error) + this.app.catch(error) } }