Skip to content

Commit

Permalink
feat(checkver): Add option to throw error as exception (ScoopInstalle…
Browse files Browse the repository at this point in the history
  • Loading branch information
CrendKing authored Apr 14, 2022
1 parent f6679c2 commit 47c0f46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions bin/auto-pr.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,7 +56,8 @@ param(
[Switch] $Request,
[Switch] $Help,
[string[]] $SpecialSnowflakes,
[Switch] $SkipUpdated
[Switch] $SkipUpdated,
[Switch] $ThrowError
)

. "$PSScriptRoot\..\lib\manifest.ps1"
Expand Down Expand Up @@ -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
}
}

Expand Down
11 changes: 9 additions & 2 deletions bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,7 +64,8 @@ param(
[Switch] $Update,
[Switch] $ForceUpdate,
[Switch] $SkipUpdated,
[String] $Version = ''
[String] $Version = '',
[Switch] $ThrowError
)

. "$PSScriptRoot\..\lib\core.ps1"
Expand Down Expand Up @@ -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
}
}
}
}

0 comments on commit 47c0f46

Please sign in to comment.