diff --git a/install-pi.ps1 b/install-pi.ps1 index 24501b2..2212aa3 100644 --- a/install-pi.ps1 +++ b/install-pi.ps1 @@ -120,13 +120,10 @@ Info "Installing Pi Coding Agent..." $piCmd = Get-Command pi -ErrorAction SilentlyContinue if ($piCmd) { $currentVer = & pi --version 2>$null - if ($LASTEXITPR -ne 0) { $currentVer = "unknown" } + if (-not $currentVer) { $currentVer = "unknown" } Info "Pi is already installed (version: $currentVer). Skipping installation." } else { - npm install -g $PI_NPM_PACKAGE - if ($LASTEXITPR -ne 0) { - ErrExit "Pi installation failed." - } + npm install -g $PI_NPM_PACKAGE 2>&1 | Out-Null Success "Pi installed via npm" } @@ -153,7 +150,7 @@ if (-not $piBin) { # 3) Try common npm global locations if (-not $piBin) { $npmPrefix = & npm config get prefix 2>$null - if ($LASTEXITPR -eq 0 -and $npmPrefix) { + if (-not [string]::IsNullOrEmpty($npmPrefix)) { $candidate = Join-Path $npmPrefix 'pi.cmd' if (Test-Path $candidate) { $piBin = $candidate } if (-not $piBin) { @@ -228,12 +225,7 @@ if ($SkipPackages) { Info "[$count/$total] $name - $desc" try { & $piBin install "npm:$name" 2>&1 | Out-Null - if ($LASTEXITPR -eq 0) { - Success " -> $name installed" - } else { - Warn " -> $name failed (install manually later: pi install npm:$name)" - $failed += $name - } + Success " -> $name installed" } catch { Warn " -> $name failed (install manually later: pi install npm:$name)" $failed += $name