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:
parent
2e034f43f2
commit
53a2617fb8
1 changed files with 6 additions and 4 deletions
|
|
@ -55,12 +55,14 @@ function Build-FromSource {
|
||||||
|
|
||||||
Write-Info "Building core CLI..."
|
Write-Info "Building core CLI..."
|
||||||
Push-Location $cloneDir
|
Push-Location $cloneDir
|
||||||
go build -o core.exe .
|
try {
|
||||||
if ($LASTEXITCODE -ne 0) {
|
go build -o core.exe .
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
Write-Err "Go build failed"
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
Write-Err "Go build failed"
|
|
||||||
}
|
}
|
||||||
Pop-Location
|
|
||||||
|
|
||||||
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
|
||||||
Move-Item (Join-Path $cloneDir "core.exe") (Join-Path $InstallDir "core.exe") -Force
|
Move-Item (Join-Path $cloneDir "core.exe") (Join-Path $InstallDir "core.exe") -Force
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue