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:
Jhin
2026-02-01 01:08:47 +00:00
committed by Tak Hoffman
parent 5c8880ed3f
commit dc8a63cb8b

View File

@@ -16,6 +16,11 @@ function resolveCommand(command: string): string {
return command;
}
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
const cmdCommands = ["npm", "pnpm", "yarn", "npx"];
if (cmdCommands.includes(basename)) {