Skip to content

Commit

Permalink
Simplify the logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Timofeev committed May 26, 2021
1 parent 8b8dca1 commit aede2b7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions images/win/scripts/Installers/Install-Haskell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
# Get 3 latest versions of GHC, use OData query for that since choco search has issues https://github.com/chocolatey/choco/issues/2271
$ODataQuery = '$filter=(Title eq ''ghc'') and (IsPrerelease eq false)&$orderby=Version desc'
$Url = "https://community.chocolatey.org/api/v2/Packages()?$ODataQuery"
$ChocoVersionsOutput = Invoke-RestMethod -Uri $Url | ForEach-Object { [Version]$_.properties.Version }
$GroupedVersions = $ChocoVersionsOutput | Group-Object { $_.ToString(2) }
$LatestMajorMinor = $GroupedVersions | ForEach-Object { [Version]$_.Name } | Sort-Object | Select-Object -last 3
$VersionsList = $GroupedVersions | Where-Object { $_.Name -in $LatestMajorMinor } | ForEach-Object { $_.Group | Select-Object -First 1 } | Sort-Object
$ChocoVersionsOutput = [Version[]](Invoke-RestMethod -Uri $Url).properties.Version
$LatestMajorMinor = $ChocoVersionsOutput | Group-Object { $_.ToString(2) } | Sort-Object { [Version]$_.Name } | Select-Object -last 3
$VersionsList = $LatestMajorMinor | ForEach-Object { $_.Group | Select-Object -First 1 } | Sort-Object

# The latest version will be installed as a default
ForEach ($version in $VersionsList)
Expand Down

0 comments on commit aede2b7

Please sign in to comment.