From a68a91bb39092aaae91f99e541f8786a3e9bb2d2 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 25 Dec 2020 19:30:49 +0100 Subject: [PATCH] Explicitly return on failure in make.ps1 --- make.ps1 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/make.ps1 b/make.ps1 index cd66b2881a87..a317ee2cef60 100644 --- a/make.ps1 +++ b/make.ps1 @@ -99,13 +99,13 @@ function Test-Command Write-Host "Testing mods..." -ForegroundColor Cyan Write-Host "Testing Tiberian Sun mod MiniYAML..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath ts --check-yaml" + InvokeCommand "$utilityPath ts --check-yaml" Write-Host "Testing Dune 2000 mod MiniYAML..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath d2k --check-yaml" + InvokeCommand "$utilityPath d2k --check-yaml" Write-Host "Testing Tiberian Dawn mod MiniYAML..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath cnc --check-yaml" + InvokeCommand "$utilityPath cnc --check-yaml" Write-Host "Testing Red Alert mod MiniYAML..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath ra --check-yaml" + InvokeCommand "$utilityPath ra --check-yaml" } function Check-Command @@ -120,10 +120,10 @@ function Check-Command if ((CheckForUtility) -eq 0) { Write-Host "Checking for explicit interface violations..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath all --check-explicit-interfaces" + InvokeCommand "$utilityPath all --check-explicit-interfaces" Write-Host "Checking for incorrect conditional trait interface overrides..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath all --check-conditional-trait-interface-overrides" + InvokeCommand "$utilityPath all --check-conditional-trait-interface-overrides" } } @@ -201,6 +201,20 @@ function WaitForInput } } +function InvokeCommand +{ + param($expression) + # $? is the return value of the called expression + # Invoke-Expression itself will always succeed, even if the invoked expression fails + # So temporarily store the return value in $success + $expression += '; $success = $?' + Invoke-Expression $expression + if ($success -eq $False) + { + exit 1 + } +} + ############################################################### ############################ Main ############################# ###############################################################