From cc0c9ba63b95b18a4e51b40148e260c541c4f485 Mon Sep 17 00:00:00 2001 From: AHuusom Date: Tue, 27 Apr 2021 10:37:12 +0200 Subject: [PATCH] [windows] Fixed version checking (#3219) --- images/win/scripts/Installers/Install-Haskell.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/images/win/scripts/Installers/Install-Haskell.ps1 b/images/win/scripts/Installers/Install-Haskell.ps1 index e34d930b..6a70d452 100644 --- a/images/win/scripts/Installers/Install-Haskell.ps1 +++ b/images/win/scripts/Installers/Install-Haskell.ps1 @@ -4,15 +4,15 @@ ################################################################################ # Get 3 latest versions of GHC -[Version[]] $ChocoVersionsOutput = & choco search ghc --allversions | Where-Object { $_.StartsWith("ghc ") -and $_ -match "Approved"} | ForEach-Object { [regex]::matches($_, "\d+(\.\d+){2,}").value } -$MajorMinorGroups = $ChocoVersionsOutput | Sort-Object -Descending | Group-Object { $_.ToString(2) } | Select-Object -First 3 +[Version[]] $ChocoVersionsOutput = & choco search ghc --allversions | Where-Object { $_.StartsWith('ghc ') -and $_ -match 'Approved' } | ForEach-Object { [regex]::matches($_, '\d+(\.\d+){2,}').value } +$MajorMinorGroups = $ChocoVersionsOutput | Group-Object { $_.ToString(2) } | Sort-Object Name -Descending | Select-Object -First 3 $VersionsList = $MajorMinorGroups | ForEach-Object { $_.Group | Select-Object -First 1 } | Sort-Object # The latest version will be installed as a default ForEach ($version in $VersionsList) { Write-Host "Installing ghc $version..." - Choco-Install -PackageName ghc -ArgumentList "--version", $version, "-m" + Choco-Install -PackageName ghc -ArgumentList '--version', $version, '-m' } # Add default version of GHC to path, because choco formula updates path on user level @@ -20,14 +20,14 @@ $DefaultGhcVersion = $VersionsList | Select-Object -Last 1 $DefaultGhcShortVersion = ([version]$DefaultGhcVersion).ToString(3) $DefaultGhcPath = Join-Path $env:ChocolateyInstall "lib\ghc.$DefaultGhcVersion\tools\ghc-$DefaultGhcShortVersion\bin" # Starting from version 9 haskell installation directory is $env:ChocolateyToolsLocation instead of $env:ChocolateyInstall\lib -if ($ghcVersion -notmatch "^[0-8]\.\d+.*") +if ($DefaultGhcShortVersion -notmatch '^[0-8]\.\d+.*') { $DefaultGhcPath = Join-Path $env:ChocolateyToolsLocation "ghc-$DefaultGhcShortVersion\bin" } Add-MachinePathItem -PathItem $DefaultGhcPath -Write-Host "Installing cabal..." +Write-Host 'Installing cabal...' Choco-Install -PackageName cabal -Invoke-PesterTests -TestFile "Haskell" +Invoke-PesterTests -TestFile 'Haskell'