()
| 85 | * `&&` on 7+ where it's the correct short-circuiting operator. |
| 86 | */ |
| 87 | export async function getPowerShellEdition(): Promise<PowerShellEdition | null> { |
| 88 | const p = await getCachedPowerShellPath() |
| 89 | if (!p) return null |
| 90 | // basename without extension, case-insensitive. Covers: |
| 91 | // C:\Program Files\PowerShell\7\pwsh.exe |
| 92 | // /opt/microsoft/powershell/7/pwsh |
| 93 | // C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe |
| 94 | const base = p |
| 95 | .split(/[/\\]/) |
| 96 | .pop()! |
| 97 | .toLowerCase() |
| 98 | .replace(/\.exe$/, '') |
| 99 | return base === 'pwsh' ? 'core' : 'desktop' |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Resets the cached PowerShell path. Only for testing. |
no test coverage detected