fix: skip extension append if command already has one
Addresses review feedback - now checks path.extname() before appending .cmd to avoid producing invalid paths like npm.cmd.cmd
This commit is contained in:
parent
5c8880ed3f
commit
dc8a63cb8b
1 changed files with 5 additions and 0 deletions
|
|
@ -16,6 +16,11 @@ function resolveCommand(command: string): string {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
const basename = path.basename(command).toLowerCase();
|
const basename = path.basename(command).toLowerCase();
|
||||||
|
// Skip if already has an extension (.cmd, .exe, .bat, etc.)
|
||||||
|
const ext = path.extname(basename);
|
||||||
|
if (ext) {
|
||||||
|
return command;
|
||||||
|
}
|
||||||
// Common npm-related commands that need .cmd extension on Windows
|
// Common npm-related commands that need .cmd extension on Windows
|
||||||
const cmdCommands = ["npm", "pnpm", "yarn", "npx"];
|
const cmdCommands = ["npm", "pnpm", "yarn", "npx"];
|
||||||
if (cmdCommands.includes(basename)) {
|
if (cmdCommands.includes(basename)) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue