diff --git a/install.ps1 b/install.ps1 index d03c8e0e11..dd0b1ce784 100644 --- a/install.ps1 +++ b/install.ps1 @@ -80,7 +80,7 @@ function Get-Spicetify { else { Write-Warning -Message "You have specified an invalid spicetify version: $v `nThe version must be in the following format: 1.2.3" Pause - exit + exit 1 } } else { @@ -98,8 +98,15 @@ function Get-Spicetify { UseBasicParsin = $true OutFile = $archivePath } - Invoke-WebRequest @Parameters - Write-Success + try { + Invoke-WebRequest @Parameters + Write-Success + } catch { + Write-Unsuccess + Write-Warning "Failed to download spicetify v$targetVersion. Reason: $_" + Pause + exit 1 + } } end { $archivePath @@ -121,9 +128,16 @@ function Add-SpicetifyToPath { } } end { - [Environment]::SetEnvironmentVariable('PATH', $path, $user) - $env:PATH = $path - Write-Success + try { + [Environment]::SetEnvironmentVariable('PATH', $path, $user) + $env:PATH = $path + Write-Success + } catch { + Write-Unsuccess + Write-Warning "Failed to add spicetify to PATH. Reason: $_" + Pause + exit 1 + } } } @@ -136,8 +150,15 @@ function Install-Spicetify { process { $archivePath = Get-Spicetify Write-Host -Object 'Extracting spicetify...' -NoNewline - Expand-Archive -Path $archivePath -DestinationPath $spicetifyFolderPath -Force - Write-Success + try { + Expand-Archive -Path $archivePath -DestinationPath $spicetifyFolderPath -Force + Write-Success + } catch { + Write-Unsuccess + Write-Warning "Failed to extract spicetify. Reason: $_" + Pause + exit 1 + } Add-SpicetifyToPath } end { @@ -158,7 +179,7 @@ if (-not (Test-PowerShellVersion)) { Write-Host -Object 'PowerShell 7 install guide:' Write-Host -Object 'https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows' Pause - exit + exit 1 } else { Write-Success @@ -175,7 +196,7 @@ if (-not (Test-Admin)) { if ($choice -eq 0) { Write-Host -Object 'spicetify installation aborted' -ForegroundColor 'Yellow' Pause - exit + exit 1 } } else { diff --git a/install.sh b/install.sh index 4d6c1221d1..263e95c01b 100755 --- a/install.sh +++ b/install.sh @@ -75,13 +75,22 @@ tar="$spicetify_install/spicetify.tar.gz" [ ! -d "$spicetify_install" ] && log "CREATING $spicetify_install" && mkdir -p "$spicetify_install" log "DOWNLOADING $download_uri" -curl --fail --location --progress-bar --output "$tar" "$download_uri" +if ! curl --fail --location --progress-bar --output "$tar" "$download_uri"; then + log "ERROR: Failed to download spicetify. Check your internet connection or if the version '$tag' exists." + exit 1 +fi log "EXTRACTING $tar" -tar xzf "$tar" -C "$spicetify_install" +if ! tar xzf "$tar" -C "$spicetify_install"; then + log "ERROR: Failed to extract spicetify. The downloaded file may be corrupted." + exit 1 +fi log "SETTING EXECUTABLE PERMISSIONS TO $exe" -chmod +x "$exe" +if ! chmod +x "$exe"; then + log "ERROR: Failed to set executable permissions on $exe. Try running with correct permissions." + exit 1 +fi log "REMOVING $tar" rm "$tar"