Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
}
}
}

Expand All @@ -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 {
Expand All @@ -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
Expand All @@ -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 {
Expand Down
15 changes: 12 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down