Skip to content

Commit 53f0e9a

Browse files
authored
feat(checkver,auto-pr): Allow passing file path (#5019)
* feat(checkver,auto-pr): Allow passing file path * changelog * reuse $App parameter * Update CHANGELOG.md
1 parent 1b5ee6f commit 53f0e9a

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
- **scoop-search:** Output PSObject, use API token ([#4997](https://github.com/ScoopInstaller/Scoop/issues/4997))
1919

20+
### Builds
21+
22+
- **checkver,auto-pr:** Allow passing file path ([#5019](https://github.com/ScoopInstaller/Scoop/issues/5019))
23+
2024
### Tests
2125

2226
- **typo:** Fix typo ('formated' -> 'formatted') ([#4217](https://github.com/ScoopInstaller/Scoop/issues/4217))

bin/auto-pr.ps1

Lines changed: 7 additions & 2 deletions
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

Lines changed: 13 additions & 7 deletions
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 {

0 commit comments

Comments
 (0)