Close scratch iteration 007 and harden runner output contracts
This commit is contained in:
@@ -31,9 +31,21 @@ function Invoke-External {
|
||||
|
||||
Push-Location $WorkingDirectory
|
||||
try {
|
||||
& $FilePath @ArgumentList
|
||||
$resolvedFilePath = $FilePath
|
||||
if (Test-Path $FilePath) {
|
||||
$resolvedFilePath = (Resolve-Path $FilePath).Path
|
||||
}
|
||||
|
||||
if ([System.IO.Path]::GetExtension($resolvedFilePath).Equals('.ps1', [System.StringComparison]::OrdinalIgnoreCase)) {
|
||||
$powershellPath = (Get-Command powershell.exe -ErrorAction Stop).Source
|
||||
& $powershellPath -NoLogo -NoProfile -ExecutionPolicy Bypass -File $resolvedFilePath @ArgumentList 2>&1 | Out-Host
|
||||
}
|
||||
else {
|
||||
& $resolvedFilePath @ArgumentList 2>&1 | Out-Host
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command failed: $FilePath $($ArgumentList -join ' ')"
|
||||
throw "Command failed: $resolvedFilePath $($ArgumentList -join ' ')"
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
||||
Reference in New Issue
Block a user