From 794f8a51aaaa3b0c6f868320ecaa9b4050e125cd Mon Sep 17 00:00:00 2001 From: Hsiao-nan Cheung Date: Fri, 1 Jul 2022 22:22:49 +0800 Subject: [PATCH] builds(checkver): Exit routine earlier if error (#5025) --- CHANGELOG.md | 1 + bin/checkver.ps1 | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fab1fbefbd..3d8ef677ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ ### Builds - **checkver,auto-pr:** Allow passing file path ([#5019](https://github.com/ScoopInstaller/Scoop/issues/5019)) +- **checkver:** Exit routine earlier if error ([#5025](https://github.com/ScoopInstaller/Scoop/issues/5025)) ### Tests diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 055a90636c..1b2fb2033e 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -224,20 +224,20 @@ while ($in_progress -gt 0) { $ver = $Version if (!$ver) { - $page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result) - $err = $ev.SourceEventArgs.Error - if ($json.checkver.script) { - $page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n")) + if (!$regex -and $replace) { + next "'replace' requires 're' or 'regex'" + continue } - + $err = $ev.SourceEventArgs.Error if ($err) { next "$($err.message)`r`nURL $url is not valid" continue } - if (!$regex -and $replace) { - next "'replace' requires 're' or 'regex'" - continue + if ($json.checkver.script) { + $page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n")) + } else { + $page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result) } if ($jsonpath) {