From fa1b42bf285c2615699ca6f6c962d7eddb3833e5 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Sun, 26 May 2024 14:30:47 +0800 Subject: [PATCH] fix(checkver): Correct variable 'regex' to 'regexp' (#5993) --- CHANGELOG.md | 1 + bin/checkver.ps1 | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 001ac5798e..373b875059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bin/checkver.ps1 b/bin/checkver.ps1 index 07d954c671..48691c872c 100644 --- a/bin/checkver.ps1 +++ b/bin/checkver.ps1 @@ -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 } @@ -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 @@ -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']