From f06fa67de5275768453bee14496bce453a5e54a7 Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Mon, 26 Mar 2018 09:02:25 -0700 Subject: [PATCH] fix: add config to hook context --- src/config.ts | 1 + src/hooks.ts | 1 + 2 files changed, 2 insertions(+) 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