Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: add config to hook context
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Mar 26, 2018
1 parent fc6ad6c commit f06fa67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ export class Config implements IConfig {
async runHook<T extends Hooks, K extends keyof T>(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)
Expand Down
1 change: 1 addition & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type Hook<K extends keyof Hooks> = (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
Expand Down

0 comments on commit f06fa67

Please sign in to comment.