( command: string, env: NodeJS.ProcessEnv, )
| 44 | } |
| 45 | |
| 46 | function findOnPath( |
| 47 | command: string, |
| 48 | env: NodeJS.ProcessEnv, |
| 49 | ): string | undefined { |
| 50 | const names = isWindows ? [`${command}.bat`, `${command}.exe`] : [command]; |
| 51 | for (const dir of (env[getPathKey(env)] ?? '').split(delimiter)) { |
| 52 | if (!dir) { |
| 53 | continue; |
| 54 | } |
| 55 | for (const name of names) { |
| 56 | const candidate = join(dir, name); |
| 57 | if (existsSync(candidate)) { |
| 58 | return candidate; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | return undefined; |
| 63 | } |
| 64 | |
| 65 | function prependToPath(env: NodeJS.ProcessEnv, dir: string): void { |
| 66 | const key = getPathKey(env); |
no test coverage detected