mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-03-23 15:52:56 +08:00
Update release
This commit is contained in:
36
Tools/StartProcess.ps1
Normal file
36
Tools/StartProcess.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
function Start-Process-And-Wait([String[][]] $Pairs, [Boolean]$Inline = $false, [String]$workingDirectory = "") {
|
||||
$processes = New-Object System.Diagnostics.Process[] $Pairs.Length
|
||||
for ($i = 0; $i -lt $Pairs.Length; $i++) {
|
||||
Write-Host " Running: $($Pairs[$i][0]) $($Pairs[$i][1])" -ForegroundColor DarkGray
|
||||
|
||||
$arguments = @{};
|
||||
if ($Pairs[$i][1] -ne "") {
|
||||
$arguments.Add("ArgumentList", $Pairs[$i][1])
|
||||
}
|
||||
$arguments.Add("PassThru", $true)
|
||||
$arguments.Add("NoNewWindow", $Inline)
|
||||
if ($workingDirectory -ne "") {
|
||||
$arguments.Add("WorkingDirectory", $workingDirectory)
|
||||
}
|
||||
|
||||
$processes[$i] = Start-Process $Pairs[$i][0] @arguments
|
||||
}
|
||||
|
||||
$failed = $false
|
||||
for ($i = 0; $i -lt $Pairs.Length; $i++) {
|
||||
$process = $processes[$i]
|
||||
$process_handle = $process.Handle
|
||||
$process.WaitForExit()
|
||||
if ($process.ExitCode -ne 0) {
|
||||
Write-Host " Crashes($($process.ExitCode)): $($Pairs[$i][0]) $($Pairs[$i][1])" -ForegroundColor Red
|
||||
$failed = $true
|
||||
}
|
||||
$process.Close()
|
||||
}
|
||||
|
||||
[Console]::ResetColor()
|
||||
|
||||
if ($failed) {
|
||||
throw "One or more processes crash"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user