mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 18:15:34 +00:00
fix(desktop): keep PowerShell window open on install errors
Add Exit-WithPause helper that waits for keypress before closing the window, so users can read error messages when fetch/download fails.
This commit is contained in:
1 parent
d9087fd0b7
commit
e1b8217e45
1 file changed
+12
-3
@@ -8,6 +8,14 @@ param([string]$Version = "")
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue" # Speeds up Invoke-WebRequest significantly
|
||||
|
||||
function Exit-WithPause {
|
||||
param([int]$Code = 0)
|
||||
Write-Host ""
|
||||
Write-Host "Press any key to exit..." -ForegroundColor Gray
|
||||
try { $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") } catch { Start-Sleep -Seconds 5 }
|
||||
exit $Code
|
||||
}
|
||||
$Repo = "nextlevelbuilder/goclaw"
|
||||
$InstallDir = Join-Path $env:LOCALAPPDATA "GoClaw Lite"
|
||||
|
||||
@@ -19,13 +27,13 @@ if (-not $Version) {
|
||||
} catch {
|
||||
Write-Host "Failed to fetch releases: $_" -ForegroundColor Red
|
||||
Write-Host "Check: https://github.com/$Repo/releases" -ForegroundColor Yellow
|
||||
exit 1
|
||||
Exit-WithPause 1
|
||||
}
|
||||
$latest = $releases | Where-Object { $_.tag_name -like "lite-v*" -and -not $_.prerelease -and -not $_.draft } | Select-Object -First 1
|
||||
if (-not $latest) {
|
||||
Write-Host "No desktop release found." -ForegroundColor Red
|
||||
Write-Host "Check: https://github.com/$Repo/releases" -ForegroundColor Yellow
|
||||
exit 1
|
||||
Exit-WithPause 1
|
||||
}
|
||||
$Version = $latest.tag_name
|
||||
}
|
||||
@@ -44,7 +52,7 @@ try {
|
||||
} catch {
|
||||
Write-Host "Download failed: $_" -ForegroundColor Red
|
||||
Write-Host "URL: $Url" -ForegroundColor Yellow
|
||||
exit 1
|
||||
Exit-WithPause 1
|
||||
}
|
||||
|
||||
# ── Extract ──
|
||||
@@ -77,3 +85,4 @@ Write-Host " Location: $InstallDir" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "-> Launching GoClaw Lite..."
|
||||
if (Test-Path $ExePath) { Start-Process $ExePath }
|
||||
Exit-WithPause 0
|
||||
Reference in new issue
Block a user