From 613e511cb26c4c98acc90dba7181df4f24e4c919 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 22 Aug 2019 11:26:19 +0300 Subject: AppVeyor: better practices --- .appveyor/build.ps1 | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.appveyor/build.ps1 b/.appveyor/build.ps1 index 80477a7..54a4516 100644 --- a/.appveyor/build.ps1 +++ b/.appveyor/build.ps1 @@ -3,6 +3,7 @@ param( ) $ErrorActionPreference = "Stop"; +Set-PSDebug -Strict function Invoke-Exe { param( @@ -27,10 +28,13 @@ function Test-AppVeyor { return Test-Path env:APPVEYOR } +function Set-AppVeyorDefaults { + $script:Platform = $env:PLATFORM +} + function Get-StackUrl { param( - [Parameter(Mandatory=$true)] - [string] $Platform + [string] $Platform = $env:PLATFORM ) if ($Platform -eq 'x86_64') { @@ -60,14 +64,20 @@ function Build-Project { Invoke-Exe { C:\sr\stack.exe build --install-ghc --arch $Platform } } -if (Test-AppVeyor) { - $cwd = pwd - $Platform = $env:PLATFORM +function Build-ProjectAppVeyor { + if (Test-AppVeyor) { + Set-AppVeyorDefaults + $appveyor_cwd = pwd + } + + try { + Install-Stack -Platform $script:Platform + Build-Project -Platform $script:Platform + } finally { + if (Test-AppVeyor) { + cd $appveyor_cwd + } + } } -Install-Stack -Platform $Platform -Build-Project -Platform $Platform - -if (Test-AppVeyor) { - cd $cwd -} +Build-ProjectAppVeyor -- cgit v1.2.3