diff --git a/src/config.ts b/src/config.ts index f9b7fd75..508a660a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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' @@ -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) diff --git a/src/hooks.ts b/src/hooks.ts index 1383e09a..ebd6c0d8 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -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 } }