File tree 1 file changed +15
-13
lines changed 1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -41,22 +41,24 @@ export async function runCommand<T extends ArgsDef = ArgsDef>(
41
41
( arg ) => ! arg . startsWith ( "-" ) ,
42
42
) ;
43
43
const subCommandName = opts . rawArgs [ subCommandArgIndex ] ;
44
- if ( ! subCommandName && ! cmd . run ) {
44
+ if ( subCommandName ) {
45
+ if ( ! subCommands [ subCommandName ] ) {
46
+ throw new CLIError (
47
+ `Unknown command \`${ subCommandName } \`` ,
48
+ "E_UNKNOWN_COMMAND" ,
49
+ ) ;
50
+ }
51
+ const subCommand = await resolveValue ( subCommands [ subCommandName ] ) ;
52
+ if ( subCommand ) {
53
+ await runCommand ( subCommand , {
54
+ rawArgs : opts . rawArgs . slice ( subCommandArgIndex + 1 ) ,
55
+ } ) ;
56
+ }
57
+ } else if ( ! cmd . run ) {
45
58
throw new CLIError ( `No command specified.` , "E_NO_COMMAND" ) ;
46
59
}
47
- if ( ! subCommands [ subCommandName ] ) {
48
- throw new CLIError (
49
- `Unknown command \`${ subCommandName } \`` ,
50
- "E_UNKNOWN_COMMAND" ,
51
- ) ;
52
- }
53
- const subCommand = await resolveValue ( subCommands [ subCommandName ] ) ;
54
- if ( subCommand ) {
55
- await runCommand ( subCommand , {
56
- rawArgs : opts . rawArgs . slice ( subCommandArgIndex + 1 ) ,
57
- } ) ;
58
- }
59
60
}
61
+
60
62
// Handle main command
61
63
if ( typeof cmd . run === "function" ) {
62
64
await cmd . run ( context ) ;
You can’t perform that action at this time.
0 commit comments