(name: string, env: NodeJS.ProcessEnv)
| 134 | } |
| 135 | |
| 136 | function windowsSystemExecutable(name: string, env: NodeJS.ProcessEnv): string { |
| 137 | const systemRoot = |
| 138 | windowsEnvironmentValue(env, "SystemRoot") || windowsEnvironmentValue(env, "windir"); |
| 139 | if (systemRoot) return join(systemRoot, "System32", name); |
| 140 | const comSpec = windowsEnvironmentValue(env, "ComSpec"); |
| 141 | if (comSpec && isAbsolute(comSpec)) return join(dirname(comSpec), name); |
| 142 | throw new Error(`Unable to resolve Windows system executable: ${name}`); |
| 143 | } |
| 144 | |
| 145 | function windowsEnvironmentValue(env: NodeJS.ProcessEnv, name: string): string | undefined { |
| 146 | const entry = Object.entries(env).find(([key]) => key.toLowerCase() === name.toLowerCase()); |
no test coverage detected