Resolve the Windows fallback shell command: prefer COMSPEC when valid, otherwise cmd.exe.
( env: NodeJS.ProcessEnv, isPathAccessible: (candidatePath: string) => boolean )
| 79 | |
| 80 | /** Resolve the Windows fallback shell command: prefer COMSPEC when valid, otherwise cmd.exe. */ |
| 81 | function getWindowsFallbackCommand( |
| 82 | env: NodeJS.ProcessEnv, |
| 83 | isPathAccessible: (candidatePath: string) => boolean |
| 84 | ): string { |
| 85 | const comspec = env.COMSPEC?.trim(); |
| 86 | if (!comspec) { |
| 87 | return "cmd.exe"; |
| 88 | } |
| 89 | |
| 90 | // If COMSPEC is a path-like value that doesn't validate, fall back to bare cmd.exe |
| 91 | // so the OS can resolve it via PATH. |
| 92 | if (isPathLikeShell(comspec) && !isPathAccessible(comspec)) { |
| 93 | return "cmd.exe"; |
| 94 | } |
| 95 | |
| 96 | return comspec; |
| 97 | } |
| 98 | |
| 99 | function isCandidateAvailable( |
| 100 | command: string, |
no test coverage detected