()
| 42 | */ |
| 43 | let cachedShell: string | undefined |
| 44 | function posixShell(): string { |
| 45 | if (cachedShell !== undefined) return cachedShell |
| 46 | if (process.platform !== 'win32') return (cachedShell = 'sh') |
| 47 | |
| 48 | const candidates: Array<string> = [] |
| 49 | if (process.env.TANSTACK_SANDBOX_SH) { |
| 50 | candidates.push(process.env.TANSTACK_SANDBOX_SH) |
| 51 | } |
| 52 | for (const dir of (process.env.PATH ?? '').split(path.delimiter)) { |
| 53 | if (/\\git\\cmd\\?$/i.test(dir)) { |
| 54 | candidates.push(path.join(dir, '..', 'usr', 'bin', 'sh.exe')) |
| 55 | candidates.push(path.join(dir, '..', 'bin', 'sh.exe')) |
| 56 | } |
| 57 | } |
| 58 | candidates.push( |
| 59 | 'C:\\Program Files\\Git\\usr\\bin\\sh.exe', |
| 60 | 'C:\\Program Files\\Git\\bin\\sh.exe', |
| 61 | ) |
| 62 | for (const candidate of candidates) { |
| 63 | if (candidate && existsSync(candidate)) return (cachedShell = candidate) |
| 64 | } |
| 65 | // Last resort: rely on PATH (a clear ENOENT if no POSIX sh is installed). |
| 66 | return (cachedShell = 'sh') |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Extra PATH dirs so a Windows git-bash `sh` can find its Unix tools (`sed`, |
no test coverage detected