File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,20 @@ async function main() {
3434 await completion . parse ( toComplete ) ;
3535 process . exit ( 0 ) ;
3636 } else {
37- console . error ( `Error: Expected '--' followed by command to complete` ) ;
38- process . exit ( 1 ) ;
37+ // Handle PowerShell case where trailing '--' gets stripped by npm.cmd
38+ // In PowerShell, args after 'complete' should be treated as completion args
39+ const isPowerShell = process . platform === 'win32' && process . env . PSModulePath ;
40+ if ( isPowerShell ) {
41+ const completion = new PackageManagerCompletion ( packageManager ) ;
42+ await setupCompletionForPackageManager ( packageManager , completion ) ;
43+ // Take args after 'complete' (args[2..]) as the completion args
44+ const toComplete = args . slice ( 2 ) ;
45+ await completion . parse ( toComplete ) ;
46+ process . exit ( 0 ) ;
47+ } else {
48+ console . error ( `Error: Expected '--' followed by command to complete` ) ;
49+ process . exit ( 1 ) ;
50+ }
3951 }
4052 }
4153
You can’t perform that action at this time.
0 commit comments