Skip to content

Commit

Permalink
Explicitly return on failure in make.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdefg30 committed Dec 29, 2020
1 parent 0bf8d22 commit a68a91b
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
}

Expand Down Expand Up @@ -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 #############################
###############################################################
Expand Down

0 comments on commit a68a91b

Please sign in to comment.