Skip to content

Commit

Permalink
feat: add param to runHook to capture errors (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley authored Feb 10, 2023
1 parent df0fd8c commit 7e7ca96
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ export class Config implements IConfig {
}
}

public async runHook<T extends keyof Hooks>(event: T, opts: Hooks[T]['options'], timeout?: number): Promise<Hook.Result<Hooks[T]['return']>> {
public async runHook<T extends keyof Hooks>(
event: T,
opts: Hooks[T]['options'],
timeout?: number,
captureErrors?: boolean,
): Promise<Hook.Result<Hooks[T]['return']>> {
debug('start %s hook', event)
const search = (m: any): Hook<T> => {
if (typeof m === 'function') return m
Expand Down Expand Up @@ -293,6 +298,7 @@ export class Config implements IConfig {
} catch (error: any) {
final.failures.push({plugin: p, error: error as Error})
debug(error)
if (!captureErrors && error.oclif?.exit !== undefined) throw error
}
}
})
Expand Down

0 comments on commit 7e7ca96

Please sign in to comment.