diff --git a/CHANGELOG.md b/CHANGELOG.md index c0c15ec326..db1b9c63d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +## [Unreleased](https://github.com/ScoopInstaller/Scoop/compare/v0.5.3...develop) + +### Features + +- **scoop-uninstall**: Allow access to `$bucket` in uninstall scripts ([#6380](https://github.com/ScoopInstaller/Scoop/issues/6380)) +- **install:** Add separator at the end of notes, highlight suggestions ([#6418](https://github.com/ScoopInstaller/Scoop/issues/6418)) + +### Bug Fixes + +- **scoop-download**: Fix function `nightly_version` not defined error ([#6386](https://github.com/ScoopInstaller/Scoop/issues/6386)) +- **scoop-uninstall:**: Correct `-Global` Switch ([#6454](https://github.com/ScoopInstaller/Scoop/issues/6454)) +- **scoop-update**: Force sync tags w/ remote branch while scoop update ([#6439](https://github.com/ScoopInstaller/Scoop/issues/6439)) +- **autoupdate:** Use origin URL to handle URLs with fragment in GitHub mode ([#6455](https://github.com/ScoopInstaller/Scoop/issues/6455)) +- **buckets|scoop-info:** Switch git log date format to ISO 8601 to avoid locale issues ([#6446](https://github.com/ScoopInstaller/Scoop/issues/6446)) +- **scoop-version:** Fix logic error caused by missing brackets ([#6463](https://github.com/ScoopInstaller/Scoop/issues/6463)) +- **core|manifest:** Avoid error messages when searching non-existent 'deprecated' directory ([#6471](https://github.com/ScoopInstaller/Scoop/issues/6471)) +- **checkver:** Allow script to run when URL fetch fails but script exists ([#6490](https://github.com/ScoopInstaller/Scoop/issues/6490)) +- **decompress:** Fix `Expand-7zipArchive` won't remove top folder if $ExtractDir depth exceeds 2 ([#6515](https://github.com/ScoopInstaller/Scoop/issues/6515)) + +### Code Refactoring + +- **output**: Replace raw prints with functions for standardized output ([#6449](https://github.com/ScoopInstaller/Scoop/issues/6449)) + ## [v0.5.3](https://github.com/ScoopInstaller/Scoop/compare/v0.5.2...v0.5.3) - 2025-08-11 ### Features diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 33a4449488..d5664df5f6 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -281,11 +281,16 @@ while ($in_progress -gt 0) { } $err = $ev.SourceEventArgs.Error if ($err) { - next "$($err.message)`r`nURL $url is not valid" - continue + if (!$script) { + next "$($err.message)`r`nURL $url is not valid" + continue + } else { + # Run script despite URL download failure + Write-Host "$($err.message)`r`nURL $url is not valid. Falling back to checkver.script ..." + } } - if ($url) { + if ($url -and !$err) { $ms = New-Object System.IO.MemoryStream $ms.Write($result, 0, $result.Length) $ms.Seek(0, 0) | Out-Null diff --git a/bin/scoop.ps1 b/bin/scoop.ps1 index fd2fd41fa7..036a05ba29 100644 --- a/bin/scoop.ps1 +++ b/bin/scoop.ps1 @@ -20,8 +20,8 @@ switch ($subCommand) { } ({ $subCommand -in @('-v', '--version') }) { Write-Host 'Current Scoop version:' - if (Test-GitAvailable -and (Test-Path "$PSScriptRoot\..\.git") -and (get_config SCOOP_BRANCH 'master') -ne 'master') { - Invoke-Git -Path "$PSScriptRoot\.." -ArgumentList @('log', 'HEAD', '-1', '--oneline') + if ((Test-GitAvailable) -and (Test-Path "$PSScriptRoot\..\.git") -and ((get_config SCOOP_BRANCH 'master') -ne 'master')) { + Invoke-Git -Path "$PSScriptRoot\.." -ArgumentList @('--no-pager', 'log', 'HEAD', '-1', '--oneline') } else { $version = Select-String -Pattern '^## \[(v[\d.]+)\].*?([\d-]+)$' -Path "$PSScriptRoot\..\CHANGELOG.md" Write-Host $version.Matches.Groups[1].Value -ForegroundColor Cyan -NoNewline @@ -31,9 +31,9 @@ switch ($subCommand) { Get-LocalBucket | ForEach-Object { $bucketLoc = Find-BucketDirectory $_ -Root - if (Test-GitAvailable -and (Test-Path "$bucketLoc\.git")) { + if ((Test-GitAvailable) -and (Test-Path "$bucketLoc\.git")) { Write-Host "'$_' bucket:" - Invoke-Git -Path $bucketLoc -ArgumentList @('log', 'HEAD', '-1', '--oneline') + Invoke-Git -Path $bucketLoc -ArgumentList @('--no-pager', 'log', 'HEAD', '-1', '--oneline') Write-Host '' } } diff --git a/bin/uninstall.ps1 b/bin/uninstall.ps1 index 2e2dc36ea8..9302dd988a 100644 --- a/bin/uninstall.ps1 +++ b/bin/uninstall.ps1 @@ -42,7 +42,7 @@ function do_uninstall($app, $global) { $architecture = $install.architecture Write-Output "Uninstalling '$app'" - Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Uninstall + Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $manifest $global $architecture # If a junction was used during install, that will have been used diff --git a/lib/autoupdate.ps1 b/lib/autoupdate.ps1 index 711f2fd6e5..fbc3ebfdee 100644 --- a/lib/autoupdate.ps1 +++ b/lib/autoupdate.ps1 @@ -3,6 +3,8 @@ function format_hash([String] $hash) { $hash = $hash.toLower() + # Workaround for GitHub API: + # `"digest": "sha256:"` if ($hash -like 'sha256:*') { $hash = $hash.Substring(7) # Remove prefix 'sha256:' } @@ -209,13 +211,14 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u $hash = $null $hashmode = $config.mode + $originurl = strip_fragment $url $basename = [System.Web.HttpUtility]::UrlDecode((url_remote_filename($url))) $substitutions = $substitutions.Clone() - $substitutions.Add('$url', (strip_fragment $url)) - $substitutions.Add('$baseurl', (strip_filename (strip_fragment $url)).TrimEnd('/')) + $substitutions.Add('$url', $originurl) + $substitutions.Add('$baseurl', (strip_filename $originurl).TrimEnd('/')) $substitutions.Add('$basename', $basename) - $substitutions.Add('$urlNoExt', (strip_ext (strip_fragment $url))) + $substitutions.Add('$urlNoExt', (strip_ext $originurl)) $substitutions.Add('$basenameNoExt', (strip_ext $basename)) debug $substitutions @@ -297,7 +300,7 @@ function get_hash_for_app([String] $app, $config, [String] $version, [String] $u } 'github' { $hashfile_url = "https://api.github.com/repos/$($matches['owner'])/$($matches['repo'])/releases" - $hash = find_hash_in_json $hashfile_url $substitutions ("$..assets[?(@.browser_download_url == '" + $url + "')].digest") + $hash = find_hash_in_json $hashfile_url $substitutions ("$..assets[?(@.browser_download_url == '" + $originurl + "')].digest") } } diff --git a/lib/buckets.ps1 b/lib/buckets.ps1 index 87bc02d287..08d6d0bd7e 100644 --- a/lib/buckets.ps1 +++ b/lib/buckets.ps1 @@ -108,7 +108,7 @@ function list_buckets { $path = Find-BucketDirectory $_ -Root if ((Test-Path (Join-Path $path '.git')) -and (Get-Command git -ErrorAction SilentlyContinue)) { $bucket.Source = Invoke-Git -Path $path -ArgumentList @('config', 'remote.origin.url') - $bucket.Updated = Invoke-Git -Path $path -ArgumentList @('log', '--format=%aD', '-n', '1') | Get-Date + $bucket.Updated = Invoke-Git -Path $path -ArgumentList @('log', '--format=%aI', '-n', '1') | Get-Date } else { $bucket.Source = friendly_path $path $bucket.Updated = (Get-Item "$path\bucket" -ErrorAction SilentlyContinue).LastWriteTime diff --git a/lib/core.ps1 b/lib/core.ps1 index 7ca7d121e2..b0e833c74b 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -90,7 +90,7 @@ function load_cfg($file) { $content = [System.IO.File]::ReadAllLines($file) return ($content | ConvertFrom-Json -ErrorAction Stop) } catch { - Write-Host "ERROR loading $file`: $($_.exception.message)" + error "loading $file`: $($_.exception.message)" } } @@ -555,7 +555,7 @@ function app_status($app, $global) { $status.hold = ($install_info.hold -eq $true) $deprecated_dir = (Find-BucketDirectory -Name $install_info.bucket -Root) + "\deprecated" - $status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + $status.deprecated = (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse -ErrorAction Ignore).FullName $manifest = manifest $app $install_info.bucket $install_info.url $status.removed = (!$manifest) diff --git a/lib/decompress.ps1 b/lib/decompress.ps1 index 3f174bf0c3..6b2a70d744 100644 --- a/lib/decompress.ps1 +++ b/lib/decompress.ps1 @@ -91,7 +91,7 @@ function Expand-7zipArchive { } else { $7zPath = Get-HelperPath -Helper 7zip } - $LogPath = "$(Split-Path $Path)\7zip.log" + $LogPath = "$(Split-Path -Path $Path)\7zip.log" $DestinationPath = $DestinationPath.TrimEnd('\') $ArgList = @('x', $Path, "-o$DestinationPath", '-xr!*.nsis', '-y') $IsTar = ((strip_ext $Path) -match '\.tar$') -or ($Path -match '\.t[abgpx]z2?$') @@ -106,13 +106,13 @@ function Expand-7zipArchive { 'Skip' { $ArgList += '-aos' } 'Rename' { $ArgList += '-aou' } } - $Status = Invoke-ExternalCommand $7zPath $ArgList -LogPath $LogPath - if (!$Status) { - abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')" + $Status = Invoke-ExternalCommand -FilePath $7zPath -ArgumentList $ArgList -LogPath $LogPath + if (-not $Status) { + abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path -path $LogPath)`n$(new_issue_msg $app $bucket 'decompress error')" } if ($IsTar) { # Check for tar - $Status = Invoke-ExternalCommand $7zPath @('l', $Path) -LogPath $LogPath + $Status = Invoke-ExternalCommand -FilePath $7zPath -ArgumentList @('l', $Path) -LogPath $LogPath if ($Status) { # get inner tar file name $TarFile = (Select-String -Path $LogPath -Pattern '[^ ]*tar$').Matches.Value @@ -121,27 +121,40 @@ function Expand-7zipArchive { abort "Failed to list files in $Path.`nNot a 7-Zip supported archive file." } } - if (!$IsTar -and $ExtractDir) { - movedir "$DestinationPath\$ExtractDir" $DestinationPath | Out-Null - # Remove temporary directory if it is empty - $ExtractDirTopPath = [string] "$DestinationPath\$($ExtractDir -replace '[\\/].*')" - if ((Get-ChildItem -Path $ExtractDirTopPath -Force -ErrorAction Ignore).Count -eq 0) { - Remove-Item -Path $ExtractDirTopPath -Recurse -Force -ErrorAction Ignore + if (-not $IsTar -and $ExtractDir) { + # Move content from $ExtractDir to destination + $null = movedir -from "$DestinationPath\$ExtractDir" -to $DestinationPath + # Remove temporary directories if not empty + $ExtractDirs = [string[]]($ExtractDir -split '[\\/]' | Where-Object -FilterScript { -not [string]::IsNullOrWhiteSpace($_) }) + $Depth = [byte] $ExtractDirs.'Count' + do { + $CurrentDir = [string] [System.IO.Path]::Combine( + $DestinationPath, ( + ($ExtractDirs | Select-Object -First $Depth) -join [System.IO.Path]::DirectorySeparatorChar + ) + ) + if ((Get-ChildItem -Path $CurrentDir -Force -ErrorAction 'Ignore').'Count' -gt 0) { + $Depth = 0 + } else { + Remove-Item -Path $CurrentDir -Recurse -Force -ErrorAction 'Ignore' + } + $Depth-- } + while ($Depth -gt 0) } - if (Test-Path $LogPath) { - Remove-Item $LogPath -Force + if (Test-Path -Path $LogPath -PathType 'Leaf') { + Remove-Item -Path $LogPath -Force } if ($Removal) { if (($Path -replace '.*\.([^\.]*)$', '$1') -eq '001') { # Remove splitted 7-zip archive parts - Get-ChildItem "$($Path -replace '\.[^\.]*$', '').???" | Remove-Item -Force + Get-ChildItem -Path "$($Path -replace '\.[^\.]*$', '').???" | Remove-Item -Force } elseif (($Path -replace '.*\.part(\d+)\.rar$', '$1')[-1] -eq '1') { # Remove splitted RAR archive parts - Get-ChildItem "$($Path -replace '\.part(\d+)\.rar$', '').part*.rar" | Remove-Item -Force + Get-ChildItem -Path "$($Path -replace '\.part(\d+)\.rar$', '').part*.rar" | Remove-Item -Force } else { # Remove original archive file - Remove-Item $Path -Force + Remove-Item -Path $Path -Force } } } @@ -248,7 +261,7 @@ function Expand-InnoArchive { switch -Regex ($ExtractDir) { '^[^{].*' { $ArgList += "-c{app}\$ExtractDir" } '^{.*' { $ArgList += "-c$ExtractDir" } - Default { $ArgList += '-c{app}' } + default { $ArgList += '-c{app}' } } if ($Switches) { $ArgList += (-split $Switches) diff --git a/lib/install.ps1 b/lib/install.ps1 index 56cfdac924..6125697967 100644 --- a/lib/install.ps1 +++ b/lib/install.ps1 @@ -285,7 +285,7 @@ function ensure_install_dir_not_in_path($dir, $global) { $fixed, $removed = find_dir_or_subdir $path "$dir" if ($removed) { - $removed | ForEach-Object { "Installer added '$(friendly_path $_)' to path. Removing." } + $removed | ForEach-Object { Write-Output "Installer added '$(friendly_path $_)' to path. Removing." } Set-EnvVar -Name 'PATH' -Value $fixed -Global:$global } @@ -359,6 +359,7 @@ function show_notes($manifest, $dir, $original_dir, $persist_dir) { Write-Output 'Notes' Write-Output '-----' Write-Output (wraptext (substitute $manifest.notes @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir })) + Write-Output '-----' } } @@ -419,7 +420,7 @@ function show_suggestions($suggested) { } if (!$fulfilled) { - Write-Host "'$app' suggests installing '$([string]::join("' or '", $feature_suggestions))'." + Write-Host "'$app' suggests installing '$([string]::join("' or '", $feature_suggestions))'." -ForegroundColor DarkYellow } } } diff --git a/lib/manifest.ps1 b/lib/manifest.ps1 index 29c898b6a7..6510dd650c 100644 --- a/lib/manifest.ps1 +++ b/lib/manifest.ps1 @@ -69,7 +69,7 @@ function Get-Manifest($app) { $manifest = manifest $app $bucket if (!$manifest) { $deprecated_dir = (Find-BucketDirectory -Name $bucket -Root) + '\deprecated' - $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse).FullName + $manifest = parse_json (Get-ChildItem $deprecated_dir -Filter "$(sanitary_path $app).json" -Recurse -ErrorAction Ignore).FullName } } } diff --git a/libexec/scoop-alias.ps1 b/libexec/scoop-alias.ps1 index 677b9337f7..2b0545abe4 100644 --- a/libexec/scoop-alias.ps1 +++ b/libexec/scoop-alias.ps1 @@ -40,7 +40,7 @@ if ($SubCommand -notin $SubCommands) { } $opt, $other, $err = getopt $Args 'v' 'verbose' -if ($err) { "scoop alias: $err"; exit 1 } +if ($err) { error "scoop alias: $err"; exit 1 } $name, $command, $description = $other $verbose = $opt.v -or $opt.verbose diff --git a/libexec/scoop-bucket.ps1 b/libexec/scoop-bucket.ps1 index d3b7728559..39d8ccf8da 100644 --- a/libexec/scoop-bucket.ps1 +++ b/libexec/scoop-bucket.ps1 @@ -34,14 +34,14 @@ $usage_rm = 'usage: scoop bucket rm ' switch ($cmd) { 'add' { if (!$name) { - ' missing' + error ' missing' $usage_add exit 1 } if (!$repo) { $repo = known_bucket_repo $name if (!$repo) { - "Unknown bucket '$name'. Try specifying ." + error "Unknown bucket '$name'. Try specifying ." $usage_add exit 1 } @@ -51,7 +51,7 @@ switch ($cmd) { } 'rm' { if (!$name) { - ' missing' + error ' missing' $usage_rm exit 1 } @@ -73,7 +73,7 @@ switch ($cmd) { exit 0 } default { - "scoop bucket: cmd '$cmd' not supported" + error "scoop bucket: cmd '$cmd' not supported" my_usage exit 1 } diff --git a/libexec/scoop-cache.ps1 b/libexec/scoop-cache.ps1 index 30e8354fca..e81a626db7 100644 --- a/libexec/scoop-cache.ps1 +++ b/libexec/scoop-cache.ps1 @@ -35,7 +35,7 @@ function cacheshow($app) { function cacheremove($app) { if (!$app) { - 'ERROR: missing' + error ' missing' my_usage exit 1 } elseif ($app -eq '*' -or $app -eq '-a' -or $app -eq '--all') { diff --git a/libexec/scoop-cleanup.ps1 b/libexec/scoop-cleanup.ps1 index 6ce40a211f..3ea5194d0f 100644 --- a/libexec/scoop-cleanup.ps1 +++ b/libexec/scoop-cleanup.ps1 @@ -16,15 +16,15 @@ . "$PSScriptRoot\..\lib\install.ps1" # persist related $opt, $apps, $err = getopt $args 'agk' 'all', 'global', 'cache' -if ($err) { "scoop cleanup: $err"; exit 1 } +if ($err) { error "scoop cleanup: $err"; exit 1 } $global = $opt.g -or $opt.global $cache = $opt.k -or $opt.cache $all = $opt.a -or $opt.all -if (!$apps -and !$all) { 'ERROR: missing'; my_usage; exit 1 } +if (!$apps -and !$all) { error ' missing'; my_usage; exit 1 } if ($global -and !(is_admin)) { - 'ERROR: you need admin rights to cleanup global apps'; exit 1 + error 'you need admin rights to cleanup global apps'; exit 1 } function cleanup($app, $global, $verbose, $cache) { diff --git a/libexec/scoop-download.ps1 b/libexec/scoop-download.ps1 index 996cb4e8e6..34a78ea952 100644 --- a/libexec/scoop-download.ps1 +++ b/libexec/scoop-download.ps1 @@ -25,6 +25,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' . "$PSScriptRoot\..\lib\manifest.ps1" # 'generate_user_manifest' 'Get-Manifest' . "$PSScriptRoot\..\lib\download.ps1" +. "$PSScriptRoot\..\lib\install.ps1" # 'nightly_version' if (get_config USE_SQLITE_CACHE) { . "$PSScriptRoot\..\lib\database.ps1" } diff --git a/libexec/scoop-help.ps1 b/libexec/scoop-help.ps1 index 54ed8a9319..18a67fa9b1 100644 --- a/libexec/scoop-help.ps1 +++ b/libexec/scoop-help.ps1 @@ -27,17 +27,17 @@ function print_summaries { $commands = commands -if(!($cmd)) { +if (!($cmd)) { Write-Host "Usage: scoop [] Available commands are listed below. Type 'scoop help ' to get more help for a specific command." print_summaries -} elseif($commands -contains $cmd) { +} elseif ($commands -contains $cmd) { print_help $cmd } else { - warn "scoop help: no such command '$cmd'" + error "scoop help: no such command '$cmd'" exit 1 } diff --git a/libexec/scoop-hold.ps1 b/libexec/scoop-hold.ps1 index 504f20a849..48f8304c9a 100644 --- a/libexec/scoop-hold.ps1 +++ b/libexec/scoop-hold.ps1 @@ -15,7 +15,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' $opt, $apps, $err = getopt $args 'g' 'global' -if ($err) { "scoop hold: $err"; exit 1 } +if ($err) { error "scoop hold: $err"; exit 1 } $global = $opt.g -or $opt.global diff --git a/libexec/scoop-info.ps1 b/libexec/scoop-info.ps1 index 1322e33a63..1c147e17c0 100644 --- a/libexec/scoop-info.ps1 +++ b/libexec/scoop-info.ps1 @@ -122,7 +122,7 @@ if ($manifest.depends) { if (Test-Path $manifest_file) { if (Get-Command git -ErrorAction Ignore) { - $gitinfo = (Invoke-Git -Path (Split-Path $manifest_file) -ArgumentList @('log', '-1', '-s', '--format=%aD#%an', $manifest_file) 2> $null) -Split '#' + $gitinfo = (Invoke-Git -Path (Split-Path $manifest_file) -ArgumentList @('log', '-1', '-s', '--format=%aI#%an', $manifest_file) 2> $null) -Split '#' } if ($gitinfo) { $item.'Updated at' = $gitinfo[0] | Get-Date diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 0fadcff09d..6af199a8b8 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -44,7 +44,7 @@ if (get_config USE_SQLITE_CACHE) { } $opt, $apps, $err = getopt $args 'giksua:' 'global', 'independent', 'no-cache', 'skip-hash-check', 'no-update-scoop', 'arch=' -if ($err) { "scoop install: $err"; exit 1 } +if ($err) { error "scoop install: $err"; exit 1 } $global = $opt.g -or $opt.global $check_hash = !($opt.s -or $opt.'skip-hash-check') diff --git a/libexec/scoop-list.ps1 b/libexec/scoop-list.ps1 index f757146d47..aded1e5ee0 100644 --- a/libexec/scoop-list.ps1 +++ b/libexec/scoop-list.ps1 @@ -17,7 +17,7 @@ $global = installed_apps $true | ForEach-Object { @{ name = $_; global = $true } $apps = @($local) + @($global) if (-not $apps) { - Write-Host "There aren't any apps installed." + warn "There aren't any apps installed." exit 1 } @@ -48,7 +48,7 @@ $apps | Where-Object { !$query -or ($_.name -match $query) } | ForEach-Object { $item.Updated = $updated $info = @() - if ((app_status $app $global).deprecated) { $info += 'Deprecated package'} + if ((app_status $app $global).deprecated) { $info += 'Deprecated package' } if ($global) { $info += 'Global install' } if (failed $app $global) { $info += 'Install failed' } if ($install_info.hold) { $info += 'Held package' } diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index 512540e8e6..1dd000a373 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -14,7 +14,7 @@ . "$PSScriptRoot\..\lib\shortcuts.ps1" $opt, $apps, $err = getopt $args 'a' 'all' -if($err) { "scoop reset: $err"; exit 1 } +if($err) { error "scoop reset: $err"; exit 1 } $all = $opt.a -or $opt.all if(!$apps -and !$all) { error ' missing'; my_usage; exit 1 } diff --git a/libexec/scoop-shim.ps1 b/libexec/scoop-shim.ps1 index 877b65b2e9..26f394dd56 100644 --- a/libexec/scoop-shim.ps1 +++ b/libexec/scoop-shim.ps1 @@ -48,7 +48,7 @@ if ($SubCommand -notin @('add', 'rm', 'list', 'info', 'alter')) { } $opt, $other, $err = getopt $Args 'g' 'global' -if ($err) { "scoop shim: $err"; exit 1 } +if ($err) { error "scoop shim: $err"; exit 1 } $global = $opt.g -or $opt.global @@ -147,8 +147,7 @@ switch ($SubCommand) { $pattern = $_ [void][Regex]::New($pattern) } catch { - Write-Host "ERROR: Invalid pattern: " -ForegroundColor Red -NoNewline - Write-Host $pattern -ForegroundColor Magenta + error "Invalid pattern: $([char]0x1b)[35m$pattern$([char]0x1b)[0m" exit 1 } } diff --git a/libexec/scoop-unhold.ps1 b/libexec/scoop-unhold.ps1 index 4e2413a340..88a859c81c 100644 --- a/libexec/scoop-unhold.ps1 +++ b/libexec/scoop-unhold.ps1 @@ -15,7 +15,7 @@ . "$PSScriptRoot\..\lib\versions.ps1" # 'Select-CurrentVersion' $opt, $apps, $err = getopt $args 'g' 'global' -if ($err) { "scoop unhold: $err"; exit 1 } +if ($err) { error "scoop unhold: $err"; exit 1 } $global = $opt.g -or $opt.global diff --git a/libexec/scoop-uninstall.ps1 b/libexec/scoop-uninstall.ps1 index 5bdd57e5d1..fdb6e8770e 100644 --- a/libexec/scoop-uninstall.ps1 +++ b/libexec/scoop-uninstall.ps1 @@ -58,6 +58,7 @@ if (!$apps) { exit 0 } $manifest = installed_manifest $app $version $global $install = install_info $app $version $global $architecture = $install.architecture + $bucket = $install.bucket Invoke-HookScript -HookType 'pre_uninstall' -Manifest $manifest -Arch $architecture @@ -74,7 +75,7 @@ if (!$apps) { exit 0 } continue } - Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global $global -Uninstall + Invoke-Installer -Path $dir -Manifest $manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $manifest $global $architecture rm_startmenu_shortcuts $manifest $global $architecture diff --git a/libexec/scoop-update.ps1 b/libexec/scoop-update.ps1 index 9d41906eca..bc590a13f6 100644 --- a/libexec/scoop-update.ps1 +++ b/libexec/scoop-update.ps1 @@ -30,7 +30,7 @@ if (get_config USE_SQLITE_CACHE) { } $opt, $apps, $err = getopt $args 'gfiksqa' 'global', 'force', 'independent', 'no-cache', 'skip-hash-check', 'quiet', 'all' -if ($err) { "scoop update: $err"; exit 1 } +if ($err) { error "scoop update: $err"; exit 1 } $global = $opt.g -or $opt.global $force = $opt.f -or $opt.force $check_hash = !($opt.s -or $opt.'skip-hash-check') @@ -136,7 +136,7 @@ function Sync-Scoop { # reset branch HEAD Invoke-Git -Path $currentdir -ArgumentList @('reset', '--hard', "origin/$configBranch", '-q') } else { - Invoke-Git -Path $currentdir -ArgumentList @('pull', '-q') + Invoke-Git -Path $currentdir -ArgumentList @('pull', '--tags', '--force', '-q') } $res = $lastexitcode @@ -341,7 +341,7 @@ function update($app, $global, $quiet = $false, $independent, $suggested, $use_c Invoke-HookScript -HookType 'pre_uninstall' -Manifest $old_manifest -Arch $architecture Write-Host "Uninstalling '$app' ($old_version)" - Invoke-Installer -Path $dir -Manifest $old_manifest -ProcessorArchitecture $architecture -Uninstall + Invoke-Installer -Path $dir -Manifest $old_manifest -ProcessorArchitecture $architecture -Global:$global -Uninstall rm_shims $app $old_manifest $global $architecture # If a junction was used during install, that will have been used @@ -400,7 +400,7 @@ if (-not ($apps -or $all)) { success 'Scoop was updated successfully!' } else { if ($global -and !(is_admin)) { - 'ERROR: You need admin rights to update global apps.'; exit 1 + error 'You need admin rights to update global apps.'; exit 1 } $outdated = @() diff --git a/libexec/scoop-virustotal.ps1 b/libexec/scoop-virustotal.ps1 index 8fe63359cf..d56eb6e8b4 100644 --- a/libexec/scoop-virustotal.ps1 +++ b/libexec/scoop-virustotal.ps1 @@ -36,7 +36,7 @@ . "$PSScriptRoot\..\lib\depends.ps1" # 'Get-Dependency' $opt, $apps, $err = getopt $args 'asnup' @('all', 'scan', 'no-depends', 'no-update-scoop', 'passthru') -if ($err) { "scoop virustotal: $err"; exit 1 } +if ($err) { error "scoop virustotal: $err"; exit 1 } $all = $apps -eq '*' -or $opt.a -or $opt.all if (!$apps -and !$all) { my_usage; exit 1 } $architecture = Get-DefaultArchitecture