52
52
#>
53
53
param (
54
54
[String ] $App = ' *' ,
55
- [Parameter (Mandatory = $true )]
56
55
[ValidateScript ( {
57
56
if (! (Test-Path $_ - Type Container)) {
58
57
throw " $_ is not a directory!"
@@ -77,8 +76,16 @@ param(
77
76
. " $PSScriptRoot \..\lib\install.ps1" # needed for hash generation
78
77
. " $PSScriptRoot \..\lib\unix.ps1"
79
78
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
+
82
89
$GitHubToken = Get-GitHubToken
83
90
84
91
# don't use $Version with $App = '*'
@@ -89,17 +96,16 @@ if ($App -eq '*' -and $Version -ne '') {
89
96
# get apps to check
90
97
$Queue = @ ()
91
98
$json = ' '
92
- Get-ChildItem $Dir " $App .json " | ForEach-Object {
99
+ $files | ForEach-Object {
93
100
$json = parse_json " $Dir \$ ( $_.Name ) "
94
101
if ($json.checkver ) {
95
102
$Queue += , @ ($_.Name , $json )
96
103
}
97
104
}
98
105
99
106
# clear any existing events
100
- Get-Event | ForEach-Object {
101
- Remove-Event $_.SourceIdentifier
102
- }
107
+ Get-Event | Remove-Event
108
+ Get-EventSubscriber | Unregister-Event
103
109
104
110
# start all downloads
105
111
$Queue | ForEach-Object {
@@ -218,20 +224,20 @@ while ($in_progress -gt 0) {
218
224
$ver = $Version
219
225
220
226
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
225
230
}
226
-
231
+ $err = $ev .SourceEventArgs.Error
227
232
if ($err ) {
228
233
next " $ ( $err.message ) `r`n URL $url is not valid"
229
234
continue
230
235
}
231
236
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 )
235
241
}
236
242
237
243
if ($jsonpath ) {
0 commit comments