Skip to content

Commit b84a210

Browse files
authored
Merge branch 'develop' into update-newton.json
2 parents 36f7579 + 794f8a5 commit b84a210

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
### Builds
2121

22+
- **checkver,auto-pr:** Allow passing file path ([#5019](https://github.com/ScoopInstaller/Scoop/issues/5019))
23+
- **checkver:** Exit routine earlier if error ([#5025](https://github.com/ScoopInstaller/Scoop/issues/5025))
2224
- **json:** Update Newton.Json to 13.0.1 ([#5026](https://github.com/ScoopInstaller/Scoop/issues/5026))
2325

2426
### Tests

bin/auto-pr.ps1

+7-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ param(
4343
[String] $Upstream,
4444
[String] $OriginBranch = 'master',
4545
[String] $App = '*',
46-
[Parameter(Mandatory = $true)]
4746
[ValidateScript( {
4847
if (!(Test-Path $_ -Type Container)) {
4948
throw "$_ is not a directory!"
@@ -64,7 +63,13 @@ param(
6463
. "$PSScriptRoot\..\lib\json.ps1"
6564
. "$PSScriptRoot\..\lib\unix.ps1"
6665

67-
$Dir = Resolve-Path $Dir
66+
if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
67+
$Dir = Split-Path $App
68+
} elseif ($Dir) {
69+
$Dir = Resolve-Path $Dir
70+
} else {
71+
throw "'-Dir' parameter required if '-App' is not a filepath!"
72+
}
6873

6974
if ((!$Push -and !$Request) -or $Help) {
7075
Write-Host @'

bin/checkver.ps1

+21-15
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#>
5353
param(
5454
[String] $App = '*',
55-
[Parameter(Mandatory = $true)]
5655
[ValidateScript( {
5756
if (!(Test-Path $_ -Type Container)) {
5857
throw "$_ is not a directory!"
@@ -77,8 +76,16 @@ param(
7776
. "$PSScriptRoot\..\lib\install.ps1" # needed for hash generation
7877
. "$PSScriptRoot\..\lib\unix.ps1"
7978

80-
$Dir = Resolve-Path $Dir
81-
$Search = $App
79+
if ($App -ne '*' -and (Test-Path $App -PathType Leaf)) {
80+
$Dir = Split-Path $App
81+
$files = Get-ChildItem $Dir (Split-Path $App -Leaf)
82+
} elseif ($Dir) {
83+
$Dir = Resolve-Path $Dir
84+
$files = Get-ChildItem $Dir "$App.json"
85+
} else {
86+
throw "'-Dir' parameter required if '-App' is not a filepath!"
87+
}
88+
8289
$GitHubToken = Get-GitHubToken
8390

8491
# don't use $Version with $App = '*'
@@ -89,17 +96,16 @@ if ($App -eq '*' -and $Version -ne '') {
8996
# get apps to check
9097
$Queue = @()
9198
$json = ''
92-
Get-ChildItem $Dir "$App.json" | ForEach-Object {
99+
$files | ForEach-Object {
93100
$json = parse_json "$Dir\$($_.Name)"
94101
if ($json.checkver) {
95102
$Queue += , @($_.Name, $json)
96103
}
97104
}
98105

99106
# clear any existing events
100-
Get-Event | ForEach-Object {
101-
Remove-Event $_.SourceIdentifier
102-
}
107+
Get-Event | Remove-Event
108+
Get-EventSubscriber | Unregister-Event
103109

104110
# start all downloads
105111
$Queue | ForEach-Object {
@@ -218,20 +224,20 @@ while ($in_progress -gt 0) {
218224
$ver = $Version
219225

220226
if (!$ver) {
221-
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
222-
$err = $ev.SourceEventArgs.Error
223-
if ($json.checkver.script) {
224-
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))
227+
if (!$regex -and $replace) {
228+
next "'replace' requires 're' or 'regex'"
229+
continue
225230
}
226-
231+
$err = $ev.SourceEventArgs.Error
227232
if ($err) {
228233
next "$($err.message)`r`nURL $url is not valid"
229234
continue
230235
}
231236

232-
if (!$regex -and $replace) {
233-
next "'replace' requires 're' or 'regex'"
234-
continue
237+
if ($json.checkver.script) {
238+
$page = Invoke-Command ([scriptblock]::Create($json.checkver.script -join "`r`n"))
239+
} else {
240+
$page = (Get-Encoding($wc)).GetString($ev.SourceEventArgs.Result)
235241
}
236242

237243
if ($jsonpath) {

0 commit comments

Comments
 (0)