Skip to content

Commit b787234

Browse files
committed
exclude pwsh from having -- required
1 parent 8e7e445 commit b787234

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bin/cli.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ const shells = ['zsh', 'bash', 'fish', 'powershell'];
99

1010
async function main() {
1111
const args = process.argv.slice(2);
12-
const isPwsh = process.platform === 'win32' && !!process.env.PSModulePath;
13-
if ( isPwsh && args.length >= 2 && args[1] === 'complete' && process.argv.indexOf('--') === -1 ) {
14-
process.argv.push('--');
15-
}
1612

1713
if (process.env.TAB_DEBUG) {
1814
console.error("RAW ARGS:", process.argv);
@@ -31,12 +27,22 @@ async function main() {
3127
}
3228

3329
const dashIndex = process.argv.indexOf('--');
30+
const isPowerShell = process.platform === 'win32' && process.env.PSModulePath !== undefined;
31+
3432
if (dashIndex !== -1) {
33+
// POSIX shells or explicit -- usage
3534
const completion = new PackageManagerCompletion(packageManager);
3635
await setupCompletionForPackageManager(packageManager, completion);
3736
const toComplete = process.argv.slice(dashIndex + 1);
3837
await completion.parse(toComplete);
3938
process.exit(0);
39+
} else if (isPowerShell && args.length > 2) {
40+
// PowerShell: -- was stripped, everything after 'complete' is what we want
41+
const completion = new PackageManagerCompletion(packageManager);
42+
await setupCompletionForPackageManager(packageManager, completion);
43+
const toComplete = args.slice(2);
44+
await completion.parse(toComplete);
45+
process.exit(0);
4046
} else {
4147
console.error(`Error: Expected '--' followed by command to complete`);
4248
process.exit(1);

0 commit comments

Comments
 (0)