diff --git a/src/config.ts b/src/config.ts index b7ab9747..741e4533 100644 --- a/src/config.ts +++ b/src/config.ts @@ -206,6 +206,7 @@ export class Config implements IConfig { async runHook(event: K, opts: T[K]) { debug('start %s hook', event) const context: Hook.Context = { + config: this, exit(code = 0) { exit(code) }, log(message: any = '') { message = typeof message === 'string' ? message : inspect(message) diff --git a/src/hooks.ts b/src/hooks.ts index 0ee98d3c..1383e09a 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -21,6 +21,7 @@ export type Hook = (this: Hook.Context, options: Hooks[K] export namespace Hook { export interface Context { + config: Config.IConfig exit(code?: number): void error(message: string | Error, options?: {code?: string, exit?: number}): void warn(message: string): void