File tree 3 files changed +19
-2
lines changed
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 6
6
/lib
7
7
/node_modules
8
8
/tmp
9
+ /.idea
10
+ /.vscode
Original file line number Diff line number Diff line change @@ -29,14 +29,16 @@ const hook: Hook.CommandNotFound = async function (opts) {
29
29
30
30
let response = ''
31
31
try {
32
- response = await ux . prompt ( `Did you mean ${ color . blueBright ( readableSuggestion ) } ? [y/n]` , { timeout : 4900 } )
32
+ response = await ux . prompt ( `Did you mean ${ color . blueBright ( readableSuggestion ) } ? [y/n]` , { timeout : 10_000 } )
33
33
} catch ( error ) {
34
34
this . log ( '' )
35
35
this . debug ( error )
36
36
}
37
37
38
38
if ( response === 'y' ) {
39
- const argv = opts . argv || process . argv . slice ( 3 , process . argv . length )
39
+ // this will split the original command from the suggested replacement, and gather the remaining args as varargs to help with situations like:
40
+ // confit set foo-bar -> confit:set:foo-bar -> config:set:foo-bar -> config:set foo-bar
41
+ const argv = opts . argv ?. length ? opts . argv : opts . id . split ( ':' ) . slice ( suggestion . split ( ':' ) . length )
40
42
return this . config . runCommand ( suggestion , argv )
41
43
}
42
44
Original file line number Diff line number Diff line change @@ -21,6 +21,19 @@ describe('command_not_found', () => {
21
21
expect ( ctx . stdout ) . to . match ( / c o m m a n d s .+ ?\n .* ?h e l p / )
22
22
} )
23
23
24
+ test
25
+ . stub ( ux , 'prompt' , yes )
26
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
+ // @ts -ignore
28
+ . stub ( process , 'argv' , [ 'username' ] )
29
+ . stdout ( )
30
+ . stderr ( )
31
+ . hook ( 'command_not_found' , { id : 'commans get' } )
32
+ . end ( 'runs hook with suggested command on yes with varargs passed' , ( ctx : any ) => {
33
+ expect ( ctx . stderr ) . to . be . contain ( 'Warning: commans get is not a @oclif/plugin-not-found command.\n' )
34
+ expect ( ctx . stdout ) . to . match ( / c o m m a n d s .+ ?\n .* ?h e l p / )
35
+ } )
36
+
24
37
test
25
38
. stderr ( )
26
39
. stub ( ux , 'prompt' , yes )
You can’t perform that action at this time.
0 commit comments