Skip to content

Commit 31ff4b3

Browse files
committed
fix: set this.matchedCommandName
1 parent 82451f4 commit 31ff4b3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/CAC.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class CAC extends EventEmitter {
2828
name: string
2929
commands: Command[]
3030
globalCommand: GlobalCommand
31-
matchedCommand: Command
31+
matchedCommand?: Command
32+
matchedCommandName?: string
3233
/**
3334
* Raw CLI arguments
3435
*/
@@ -147,14 +148,18 @@ class CAC extends EventEmitter {
147148

148149
private setParsedInfo(
149150
{ args, options, rawOptions }: MriResult,
150-
matchedCommand?: Command
151+
matchedCommand?: Command,
152+
matchedCommandName?: string
151153
) {
152154
this.args = args
153155
this.options = options
154156
this.rawOptions = rawOptions
155157
if (matchedCommand) {
156158
this.matchedCommand = matchedCommand
157159
}
160+
if (matchedCommandName) {
161+
this.matchedCommandName = matchedCommandName
162+
}
158163
return this
159164
}
160165

@@ -186,7 +191,7 @@ class CAC extends EventEmitter {
186191
...mriResult,
187192
args: mriResult.args.slice(1)
188193
}
189-
this.setParsedInfo(parsedInfo, command)
194+
this.setParsedInfo(parsedInfo, command, commandName)
190195
this.emit(`command:${commandName}`, command)
191196
}
192197
}

0 commit comments

Comments
 (0)