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

Commit e747712

Browse files
committed
fix: expose initDebug()
1 parent 2361af6 commit e747712

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/command.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,9 @@ export default abstract class Command {
101101

102102
protected async init(argv: string[], opts: Config.ICommandOptions) {
103103
this.config = opts.config || await Config.read({root: opts.root || parentModule!})
104-
g['http-call'] = g['http-call'] || {}
105-
g['http-call']!.userAgent = this.config.userAgent
106-
this.debug = require('debug')(`cli:command:${this.ctor.id || this.config.name}`)
104+
this.initDebug()
107105
this.debug('init version: %s argv: %o', this.ctor._base, argv)
108106
cli.config.context.command = _.compact([this.ctor.id, ...argv]).join(' ')
109-
cli.config.context.version = this.config.userAgent
110-
cli.config.debug = !!this.config.debug
111-
cli.config.errlog = this.config.errlog
112107
try {
113108
const parse = await deps.Parser.parse({
114109
argv,
@@ -127,6 +122,15 @@ export default abstract class Command {
127122
}
128123
}
129124

125+
protected initDebug() {
126+
g['http-call'] = g['http-call'] || {}
127+
g['http-call']!.userAgent = this.config.userAgent
128+
this.debug = require('debug')(`@dxcli/command:${this.ctor.id || this.config.name}`)
129+
cli.config.context.version = this.config.userAgent
130+
if (this.config.debug) cli.config.debug = true
131+
cli.config.errlog = this.config.errlog
132+
}
133+
130134
protected async done() {
131135
try {
132136
await cli.done()

0 commit comments

Comments
 (0)