fix: prevent install.ps1 from crashing PowerShell on error

When run via `irm ... | iex`, `exit` terminates the entire PowerShell
session. Wrapped the installer in a function and replaced all `exit`
calls with `return` so errors are reported cleanly without killing
the terminal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
noah
2026-04-16 11:13:51 +02:00
parent 2c756d2d27
commit e76c808eee
+13 -10
View File
@@ -1,8 +1,7 @@
# Transmute CLI installer for Windows
# Usage: irm https://raw.githubusercontent.com/noauf/Transmute/main/install.ps1 | iex
$ErrorActionPreference = "Stop"
function Install-Transmute {
$REPO = "noauf/Transmute"
$BINARY = "transmute"
@@ -12,12 +11,11 @@ Write-Host " ======================"
Write-Host ""
# Detect architecture
$ARCH = if ([System.Environment]::Is64BitOperatingSystem) {
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x86_64" }
} else {
if (-not [System.Environment]::Is64BitOperatingSystem) {
Write-Host " Error: 32-bit Windows is not supported" -ForegroundColor Red
exit 1
return
}
$ARCH = if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") { "arm64" } else { "x86_64" }
Write-Host " OS: windows"
Write-Host " Arch: $ARCH"
@@ -32,12 +30,12 @@ try {
$TAG = $release.tag_name
} catch {
Write-Host " Error: could not fetch latest release: $_" -ForegroundColor Red
exit 1
return
}
if (-not $TAG) {
Write-Host " Error: could not determine latest release" -ForegroundColor Red
exit 1
return
}
Write-Host " Latest version: $TAG"
@@ -65,7 +63,7 @@ try {
if (-not (Test-Path $EXE_SOURCE)) {
Write-Host " Error: could not find $EXE_NAME in archive" -ForegroundColor Red
exit 1
return
}
# Determine install directory
@@ -76,7 +74,7 @@ try {
Copy-Item -Path $EXE_SOURCE -Destination $INSTALL_PATH -Force
Write-Host ""
Write-Host " Installed transmute $TAG to $INSTALL_PATH"
Write-Host " Installed transmute $TAG to $INSTALL_PATH" -ForegroundColor Green
Write-Host ""
# Add to PATH if not already there
@@ -94,6 +92,11 @@ try {
Write-Host " transmute --help Show all options"
Write-Host ""
} catch {
Write-Host " Error: $_" -ForegroundColor Red
} finally {
Remove-Item -Recurse -Force $TMP_DIR -ErrorAction SilentlyContinue
}
}
Install-Transmute