Files
orca/src/main/providers/windows-powershell.ts
T
Brennan BensonandNeil 6cf52518e2 Fix explicit PowerShell 7 terminal selection on Windows (#6876)
* Fix explicit PowerShell 7 terminal selection

* Make WSL UNC readDir test portable

---------

Co-authored-by: Neil <neil@stably.ai>
2026-06-30 03:48:25 -07:00

51 lines
1.3 KiB
TypeScript

export type WindowsPowerShellImplementation = 'auto' | 'powershell.exe' | 'pwsh.exe'
export type WindowsPowerShellShellFamily =
| 'powershell.exe'
| 'pwsh.exe'
| 'cmd.exe'
| 'wsl.exe'
| undefined
export function shouldProbeWindowsPowerShellAvailability(args: {
shellFamily: WindowsPowerShellShellFamily
implementation: WindowsPowerShellImplementation | undefined
}): boolean {
return (
args.shellFamily === 'powershell.exe' &&
(args.implementation === undefined || args.implementation === 'auto')
)
}
/** Resolve which PowerShell executable to spawn right now on Windows.
*
* Why: explicit pwsh.exe choices must not be downgraded by a transient cold
* availability probe; the spawn chain handles true absence with a safe fallback.
*/
export function resolveEffectiveWindowsPowerShell(args: {
shellFamily: WindowsPowerShellShellFamily
implementation: WindowsPowerShellImplementation | undefined
pwshAvailable: boolean
}): 'powershell.exe' | 'pwsh.exe' | null {
if (args.shellFamily === 'pwsh.exe') {
return 'pwsh.exe'
}
if (args.shellFamily !== 'powershell.exe') {
return null
}
if (args.implementation === 'powershell.exe') {
return 'powershell.exe'
}
if (args.implementation === 'pwsh.exe') {
return 'pwsh.exe'
}
if (args.pwshAvailable) {
return 'pwsh.exe'
}
return 'powershell.exe'
}