Skip to content

Commit

Permalink
fix(checkver): Correct variable 'regex' to 'regexp' (#5993)
Browse files Browse the repository at this point in the history
  • Loading branch information
chawyehsu authored May 26, 2024
1 parent 700a2f4 commit fa1b42b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- **scoop-download|install|update:** Use consistent options ([#5956](https://github.com/ScoopInstaller/Scoop/issues/5956))
- **core:** Fix "Invoke-ExternalCommand" quoting rules ([#5945](https://github.com/ScoopInstaller/Scoop/issues/5945))
- **scoop-info:** Fix download size estimating ([#5958](https://github.com/ScoopInstaller/Scoop/issues/5958))
- **checkver:** Correct variable 'regex' to 'regexp' ([#5993](https://github.com/ScoopInstaller/Scoop/issues/5993))

### Code Refactoring

Expand Down
14 changes: 7 additions & 7 deletions bin/checkver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ while ($in_progress -gt 0) {
$ver = $Version

if (!$ver) {
if (!$regex -and $replace) {
if (!$regexp -and $replace) {
next "'replace' requires 're' or 'regex'"
continue
}
Expand All @@ -300,7 +300,7 @@ while ($in_progress -gt 0) {

if ($jsonpath) {
# Return only a single value if regex is absent
$noregex = [String]::IsNullOrEmpty($regex)
$noregex = [String]::IsNullOrEmpty($regexp)
# If reverse is ON and regex is ON,
# Then reverse would have no effect because regex handles reverse
# on its own
Expand Down Expand Up @@ -348,19 +348,19 @@ while ($in_progress -gt 0) {
}

if ($regexp) {
$regex = New-Object System.Text.RegularExpressions.Regex($regexp)
$re = New-Object System.Text.RegularExpressions.Regex($regexp)
if ($reverse) {
$match = $regex.Matches($page) | Select-Object -Last 1
$match = $re.Matches($page) | Select-Object -Last 1
} else {
$match = $regex.Matches($page) | Select-Object -First 1
$match = $re.Matches($page) | Select-Object -First 1
}

if ($match -and $match.Success) {
$matchesHashtable = @{}
$regex.GetGroupNames() | ForEach-Object { $matchesHashtable.Add($_, $match.Groups[$_].Value) }
$re.GetGroupNames() | ForEach-Object { $matchesHashtable.Add($_, $match.Groups[$_].Value) }
$ver = $matchesHashtable['1']
if ($replace) {
$ver = $regex.Replace($match.Value, $replace)
$ver = $re.Replace($match.Value, $replace)
}
if (!$ver) {
$ver = $matchesHashtable['version']
Expand Down

0 comments on commit fa1b42b

Please sign in to comment.