mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 03:49:40 -08:00
chore(pwsh): install.ps1 compatibility features
This commit is contained in:
parent
cdc560c7bd
commit
4aa14e218a
|
@ -26,22 +26,24 @@ https://ohmyposh.dev/docs/installation/linux
|
|||
"@
|
||||
exit
|
||||
}
|
||||
|
||||
$installer = ''
|
||||
$arch = (Get-CimInstance -Class Win32_Processor -Property Architecture).Architecture
|
||||
$arch = (Get-CimInstance -Class Win32_Processor -Property Architecture).Architecture | Select-Object -First 1
|
||||
switch ($arch) {
|
||||
0 { $installer = "install-386.exe" } # x86
|
||||
5 { $installer = "install-arm64.exe" } # ARM
|
||||
9 {
|
||||
if ([Environment]::Is64BitOperatingSystem) {
|
||||
$installer = "install-amd64.exe"
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$installer = "install-386.exe"
|
||||
}
|
||||
}
|
||||
12 { $installer = "install-arm64.exe" } # Surface Pro X
|
||||
}
|
||||
|
||||
if ($installer -eq '') {
|
||||
if ([string]::IsNullOrEmpty($installer)) {
|
||||
Write-Host @"
|
||||
The installer for system architecture ($arch) is not available.
|
||||
"@
|
||||
|
@ -49,8 +51,26 @@ The installer for system architecture ($arch) is not available.
|
|||
}
|
||||
|
||||
Write-Host "Downloading $installer..."
|
||||
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'exe' } -PassThru
|
||||
|
||||
# validate the availability of New-TemporaryFile
|
||||
if (Get-Command -Name New-TemporaryFile -ErrorAction SilentlyContinue) {
|
||||
$tmp = New-TemporaryFile | Rename-Item -NewName { $_ -replace 'tmp$', 'exe' } -PassThru
|
||||
}
|
||||
else {
|
||||
$tmp = New-Item -Path $env:TEMP -Name ([System.IO.Path]::GetRandomFileName() -replace '\.\w+$', '.exe') -Force -ItemType File
|
||||
}
|
||||
$url = "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/$installer"
|
||||
|
||||
# check if we can make https requests and download the binary
|
||||
try {
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
Invoke-WebRequest -Uri $url -Method Head | Where-Object -FilterScript { $_.StatusCode -ne 200 } # Suppress success output
|
||||
}
|
||||
catch {
|
||||
Write-Host "Unable to download $installer. Please check your internet connection."
|
||||
exit
|
||||
}
|
||||
|
||||
Invoke-WebRequest -OutFile $tmp $url
|
||||
Write-Host 'Running installer...'
|
||||
$installMode = "/CURRENTUSER"
|
||||
|
|
Loading…
Reference in a new issue