(env: NodeJS.ProcessEnv = process.env)
| 36 | * Reads PATH from an environment object with Windows casing compatibility. |
| 37 | */ |
| 38 | export function getEnvPath(env: NodeJS.ProcessEnv = process.env): string { |
| 39 | if (process.platform !== 'win32') { |
| 40 | return env.PATH ?? ''; |
| 41 | } |
| 42 | |
| 43 | const pathKeys = Object.keys(env).filter(key => key.toLowerCase() === 'path'); |
| 44 | |
| 45 | for (let index = pathKeys.length - 1; index >= 0; index--) { |
| 46 | const value = env[pathKeys[index]]; |
| 47 | if (value !== undefined) { |
| 48 | return value; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return ''; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Writes PATH to an environment object with normalized Windows casing. |
no test coverage detected