refactor: use try/finally for Push-Location cleanup

Ensures Pop-Location is always called, even if Write-Err exits early.
Makes the cleanup pattern consistent and easier to maintain.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
unknown 2026-02-01 00:11:34 +11:00
parent 2e034f43f2
commit 53a2617fb8
No known key found for this signature in database
GPG key ID: FE478DD75EE21194

View file

@ -55,12 +55,14 @@ function Build-FromSource {
Write-Info "Building core CLI..."
Push-Location $cloneDir
try {
go build -o core.exe .
if ($LASTEXITCODE -ne 0) {
Pop-Location
Write-Err "Go build failed"
}
} finally {
Pop-Location
}
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Move-Item (Join-Path $cloneDir "core.exe") (Join-Path $InstallDir "core.exe") -Force