Files
orca/src/main/pwsh.ts
T
SSWSer 6f606114a0 feat: add PowerShell 7+ support for Windows terminals
Adds PowerShell 7+ support for Windows terminal selection, with Auto resolving to pwsh.exe when available and falling back to Windows PowerShell.
2026-05-02 16:06:11 -07:00

32 lines
720 B
TypeScript

import { execFileSync } from 'child_process'
// Cached pwsh availability check — evaluated once per process lifetime
let pwshAvailableCache: boolean | null = null
/**
* Check whether pwsh.exe is available on this Windows machine.
* Result is cached for the process lifetime.
*/
export function isPwshAvailable(): boolean {
if (pwshAvailableCache !== null) {
return pwshAvailableCache
}
if (process.platform !== 'win32') {
pwshAvailableCache = false
return false
}
try {
execFileSync('pwsh.exe', ['-Version'], {
stdio: ['pipe', 'pipe', 'pipe'],
timeout: 5000
})
pwshAvailableCache = true
} catch {
pwshAvailableCache = false
}
return pwshAvailableCache
}