feat(checkver): Add option to throw error as exception (#4867)

This commit is contained in:
CrendKing
2022-04-14 09:08:56 -07:00
committed by GitHub
parent f6679c2170
commit 47c0f46d58
3 changed files with 16 additions and 5 deletions

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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
}
}
}
}