Skip to content

Commit

Permalink
(GH-802) PowerShell Host - Exit codes should return
Browse files Browse the repository at this point in the history
When running any exit code, ensure that the PowerShell host also
receives the error so that it can exit properly.
  • Loading branch information
ferventcoder committed Jun 16, 2016
1 parent 69266f3 commit 308888e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ if ($env:ChocolateyExitCode -ne $null -and $env:ChocolateyExitCode -ne '') {
$exitCode = $env:ChocolateyExitCode
}

if ($exitCode -ne 0) {
Set-PowerShellExitCode $exitCode
}

Exit $exitCode
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ param (
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

$host.SetShouldExit($exitCode);
try {
$host.SetShouldExit($exitCode);
} catch {
Write-Warning "Unable to set host exit code"
}

$env:ChocolateyExitCode = $exitCode;
}

0 comments on commit 308888e

Please sign in to comment.