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

Commit

Permalink
fix: expose initDebug()
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent 2361af6 commit e747712
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,9 @@ export default abstract class Command {

protected async init(argv: string[], opts: Config.ICommandOptions) {
this.config = opts.config || await Config.read({root: opts.root || parentModule!})
g['http-call'] = g['http-call'] || {}
g['http-call']!.userAgent = this.config.userAgent
this.debug = require('debug')(`cli:command:${this.ctor.id || this.config.name}`)
this.initDebug()
this.debug('init version: %s argv: %o', this.ctor._base, argv)
cli.config.context.command = _.compact([this.ctor.id, ...argv]).join(' ')
cli.config.context.version = this.config.userAgent
cli.config.debug = !!this.config.debug
cli.config.errlog = this.config.errlog
try {
const parse = await deps.Parser.parse({
argv,
Expand All @@ -127,6 +122,15 @@ export default abstract class Command {
}
}

protected initDebug() {
g['http-call'] = g['http-call'] || {}
g['http-call']!.userAgent = this.config.userAgent
this.debug = require('debug')(`@dxcli/command:${this.ctor.id || this.config.name}`)
cli.config.context.version = this.config.userAgent
if (this.config.debug) cli.config.debug = true
cli.config.errlog = this.config.errlog
}

protected async done() {
try {
await cli.done()
Expand Down

0 comments on commit e747712

Please sign in to comment.