(command: string, env: NodeJS.ProcessEnv, cwd: string)
| 112 | } |
| 113 | |
| 114 | function resolveWindowsCommand(command: string, env: NodeJS.ProcessEnv, cwd: string): string { |
| 115 | if (isAbsolute(command) || /[\\/]/.test(command)) { |
| 116 | return resolve(cwd, command); |
| 117 | } |
| 118 | const extensions = (windowsEnvironmentValue(env, "PATHEXT") || ".COM;.EXE;.BAT;.CMD") |
| 119 | .split(";") |
| 120 | .filter(Boolean) |
| 121 | .map((extension) => extension.toLowerCase()); |
| 122 | const candidates = extensions.includes("") |
| 123 | ? [command] |
| 124 | : [command, ...extensions.map((extension) => `${command}${extension}`)]; |
| 125 | for (const directory of (windowsEnvironmentValue(env, "PATH") || "") |
| 126 | .split(delimiter) |
| 127 | .filter(Boolean)) { |
| 128 | for (const candidate of candidates) { |
| 129 | const filePath = resolve(cwd, directory, candidate); |
| 130 | if (existsSync(filePath)) return filePath; |
| 131 | } |
| 132 | } |
| 133 | throw new Error(`Unable to resolve Windows Codex command: ${command}`); |
| 134 | } |
| 135 | |
| 136 | function windowsSystemExecutable(name: string, env: NodeJS.ProcessEnv): string { |
| 137 | const systemRoot = |
no test coverage detected