Skip to content

Commit a31b10c

Browse files
committed
rm check cli
1 parent 58e4a65 commit a31b10c

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

bin/package-manager-completion.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import {
22
spawnSync,
33
type SpawnSyncOptionsWithStringEncoding,
44
} from 'child_process';
5-
import fs from 'node:fs';
65
import path from 'node:path';
76
import { RootCommand } from '../src/t.js';
87

@@ -30,26 +29,12 @@ function runCompletionCommand(
3029
): string {
3130
const args = [...leadingArgs, 'complete', '--', ...completionArgs];
3231

33-
// In a PowerShell host, go through powershell.exe so .ps1 shims work.
34-
if (isPowerShellEnv) {
35-
if (process.env.TAB_DEBUG) {
36-
console.error('[DEBUG] runCompletionCommand via powershell:', {
37-
command,
38-
args,
39-
});
40-
}
32+
// PowerShell: prefer invoking via powershell.exe so .ps1 shims are resolved.
33+
if (isPowerShellEnv && path.extname(command) === '') {
4134
return runCompletionViaPowerShell(command, args);
4235
}
4336

44-
const targetCommand = preferCmdShim(command);
45-
if (process.env.TAB_DEBUG) {
46-
console.error('[DEBUG] runCompletionCommand via cmd path:', {
47-
command,
48-
targetCommand,
49-
args,
50-
});
51-
}
52-
const result = spawnSync(targetCommand, args, completionSpawnOptions);
37+
const result = spawnSync(command, args, completionSpawnOptions);
5338

5439
return (result.stdout ?? '').trim();
5540
}
@@ -173,17 +158,3 @@ export class PackageManagerCompletion extends RootCommand {
173158
return super.parse(args);
174159
}
175160
}
176-
177-
function preferCmdShim(command: string): string {
178-
if (process.platform !== 'win32') return command;
179-
if (path.extname(command) !== '') return command;
180-
181-
const pathEntries = (process.env.PATH || '').split(path.delimiter);
182-
for (const entry of pathEntries) {
183-
const candidate = path.join(entry, `${command}.cmd`);
184-
if (fs.existsSync(candidate)) {
185-
return `${command}.cmd`;
186-
}
187-
}
188-
return command;
189-
}

0 commit comments

Comments
 (0)