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

Commit

Permalink
fix: add debug to hook context
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Apr 9, 2018
1 parent 60e1521 commit 8c9d9bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CLIError, error, exit, warn} from '@oclif/errors'
import * as os from 'os'
import * as path from 'path'
import {inspect} from 'util'
import {format} from 'util'

import {Command} from './command'
import Debug from './debug'
Expand Down Expand Up @@ -228,10 +228,10 @@ export class Config implements IConfig {
debug('start %s hook', event)
const context: Hook.Context = {
config: this,
debug: require('debug')([this.bin, 'hooks', event].join(':')),
exit(code = 0) { exit(code) },
log(message: any = '') {
message = typeof message === 'string' ? message : inspect(message)
process.stdout.write(message + '\n')
log(message?: any, ...args: any[]) {
process.stdout.write(format(message, ...args) + '\n')
},
error(message, options: {code?: string, exit?: number} = {}) {
error(message, options)
Expand Down
3 changes: 2 additions & 1 deletion src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export namespace Hook {
exit(code?: number): void
error(message: string | Error, options?: {code?: string, exit?: number}): void
warn(message: string): void
log(message?: any): void
log(message?: any, ...args: any[]): void
debug(...args: any[]): void
}
}

0 comments on commit 8c9d9bd

Please sign in to comment.