(bin: string, env: NodeJS.ProcessEnv)
| 100 | } |
| 101 | |
| 102 | function getWindowsPathCandidates(bin: string, env: NodeJS.ProcessEnv): string[] { |
| 103 | if (path.extname(bin)) return [bin]; |
| 104 | |
| 105 | const extensions = (env.PATHEXT || ".COM;.EXE;.BAT;.CMD") |
| 106 | .split(";") |
| 107 | .map((ext) => ext.trim().toLowerCase()) |
| 108 | .filter(Boolean); |
| 109 | // The Windows installer ships plannotator.exe. Avoid auto-resolving .cmd/.bat |
| 110 | // shims because those require cmd.exe and would reintroduce shell tokenization. |
| 111 | const executableExtensions = extensions.filter((ext) => ext !== ".cmd" && ext !== ".bat"); |
| 112 | const preferred = [".exe", ".com"]; |
| 113 | const orderedExtensions = [ |
| 114 | ...preferred.filter((ext) => executableExtensions.includes(ext)), |
| 115 | ...executableExtensions.filter((ext) => !preferred.includes(ext)), |
| 116 | ]; |
| 117 | |
| 118 | return [...orderedExtensions.map((ext) => `${bin}${ext}`), bin]; |
| 119 | } |
| 120 | |
| 121 | export function resolveWindowsCliCommand(bin: string, env: NodeJS.ProcessEnv = process.env): string | undefined { |
| 122 | const pathValue = env.PATH || ""; |
no outgoing calls
no test coverage detected