diff --git a/CHANGELOG.md b/CHANGELOG.md index a63b6b8ac..33c766e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features +- **checkver:** Add option to throw error as exception ([#4863](https://github.com/ScoopInstaller/Scoop/issues/4863)) - **install:** Allow downloading from private repositories ([#4254](https://github.com/ScoopInstaller/Scoop/issues/4243)) ### Bug Fixes diff --git a/bin/auto-pr.ps1 b/bin/auto-pr.ps1 index a78a4153f..aa70d3725 100644 --- a/bin/auto-pr.ps1 +++ b/bin/auto-pr.ps1 @@ -23,6 +23,8 @@ An array of manifests, which should be updated all the time. (-ForceUpdate parameter to checkver) .PARAMETER SkipUpdated Updated manifests will not be shown. +.PARAMETER ThrowError + Throw error as exception instead of just printing it. .EXAMPLE PS BUCKETROOT > .\bin\auto-pr.ps1 'someUsername/repository:branch' -Request .EXAMPLE @@ -54,7 +56,8 @@ param( [Switch] $Request, [Switch] $Help, [string[]] $SpecialSnowflakes, - [Switch] $SkipUpdated + [Switch] $SkipUpdated, + [Switch] $ThrowError ) . "$PSScriptRoot\..\lib\manifest.ps1" @@ -160,11 +163,11 @@ if ($Push) { execute "hub push origin $OriginBranch" } -. "$PSScriptRoot\checkver.ps1" -App $App -Dir $Dir -Update -SkipUpdated:$SkipUpdated +. "$PSScriptRoot\checkver.ps1" -App $App -Dir $Dir -Update -SkipUpdated:$SkipUpdated -ThrowError:$ThrowError if ($SpecialSnowflakes) { Write-Host "Forcing update on our special snowflakes: $($SpecialSnowflakes -join ',')" -ForegroundColor DarkCyan $SpecialSnowflakes -split ',' | ForEach-Object { - . "$PSScriptRoot\checkver.ps1" $_ -Dir $Dir -ForceUpdate + . "$PSScriptRoot\checkver.ps1" $_ -Dir $Dir -ForceUpdate -ThrowError:$ThrowError } } diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index e5924691d..dbdab850f 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -17,6 +17,8 @@ Updated manifests will not be shown. .PARAMETER Version Update manifest to specific version. +.PARAMETER ThrowError + Throw error as exception instead of just printing it. .EXAMPLE PS BUCKETROOT > .\bin\checkver.ps1 Check all manifest inside default directory. @@ -62,7 +64,8 @@ param( [Switch] $Update, [Switch] $ForceUpdate, [Switch] $SkipUpdated, - [String] $Version = '' + [String] $Version = '', + [Switch] $ThrowError ) . "$PSScriptRoot\..\lib\core.ps1" @@ -336,7 +339,11 @@ while ($in_progress -gt 0) { try { Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable } catch { - error $_.Exception.Message + if ($ThrowError) { + throw $_ + } else { + error $_.Exception.Message + } } } }