From 15778b7a5fe8c3385e6bded6e0a4a07171b382a4 Mon Sep 17 00:00:00 2001 From: unknown <49066403+bodane@users.noreply.github.com> Date: Sun, 1 Feb 2026 02:00:26 +1100 Subject: [PATCH] fix: address CodeRabbit review feedback - Separate local declaration from assignment to avoid masking errors (SC2155) - Add exit code check after Homebrew installer execution - Add exit code check after NodeSource setup script execution - Add LASTEXITCODE check after Chocolatey installer execution Co-Authored-By: Claude Opus 4.5 --- scripts/install-core.sh | 11 ++++++----- scripts/install-deps.ps1 | 3 +++ scripts/install-deps.sh | 10 ++++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/install-core.sh b/scripts/install-core.sh index 1d38714..8c1f23f 100755 --- a/scripts/install-core.sh +++ b/scripts/install-core.sh @@ -99,11 +99,12 @@ check_not_symlink() { # Try to download pre-built binary with integrity verification download_binary() { - local os=$(detect_os) - local arch=$(detect_arch) - local binary_name="core-${os}-${arch}" - local binary_url="https://github.com/$REPO/releases/download/$VERSION/${binary_name}" - local checksum_url="https://github.com/$REPO/releases/download/$VERSION/checksums.txt" + local os arch binary_name binary_url checksum_url + os=$(detect_os) + arch=$(detect_arch) + binary_name="core-${os}-${arch}" + binary_url="https://github.com/$REPO/releases/download/$VERSION/${binary_name}" + checksum_url="https://github.com/$REPO/releases/download/$VERSION/checksums.txt" if [[ "$os" == "windows" ]]; then binary_name="${binary_name}.exe" diff --git a/scripts/install-deps.ps1 b/scripts/install-deps.ps1 index e9c70b3..e3573c6 100644 --- a/scripts/install-deps.ps1 +++ b/scripts/install-deps.ps1 @@ -40,6 +40,9 @@ function Install-Chocolatey { Write-Info "Executing Chocolatey installer..." & $tempScript + if ($LASTEXITCODE -ne 0) { + Write-Err "Chocolatey installation failed with exit code $LASTEXITCODE" + } } finally { # Clean up temp file if (Test-Path $tempScript) { diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index 387aa36..39c2412 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -88,7 +88,10 @@ install_brew() { error "Failed to download Homebrew installer" } - /bin/bash "$temp_script" + /bin/bash "$temp_script" || { + rm -f "$temp_script" + error "Homebrew installation failed" + } rm -f "$temp_script" # Add to PATH for this session @@ -232,7 +235,10 @@ setup_linux_apt() { error "Failed to download NodeSource setup script" } - sudo -E bash "$temp_script" + sudo -E bash "$temp_script" || { + rm -f "$temp_script" + error "NodeSource setup failed" + } rm -f "$temp_script" sudo apt-get install -y nodejs fi