@@ -560,28 +560,30 @@ function Copy-Directory($Src, $Dst) {
560
560
561
561
function Invoke-Program () {
562
562
[CmdletBinding (PositionalBinding = $false )]
563
- param (
563
+ param
564
+ (
564
565
[Parameter (Position = 0 , Mandatory = $true )]
565
566
[string ] $Executable ,
566
- [switch ] $OutNull = $false ,
567
+ [switch ] $Silent ,
568
+ [switch ] $OutNull ,
567
569
[string ] $OutFile = " " ,
568
570
[string ] $ErrorFile = " " ,
569
571
[Parameter (Position = 1 , ValueFromRemainingArguments )]
570
- [string []] $Args
572
+ [string []] $ExecutableArgs
571
573
)
572
574
573
575
if ($ToBatch ) {
574
576
# Print the invocation in batch file-compatible format
575
577
$OutputLine = " `" $Executable `" "
576
578
$ShouldBreakLine = $false
577
- for ($i = 0 ; $i -lt $Args .Length ; $i ++ ) {
579
+ for ($i = 0 ; $i -lt $ExecutableArgs .Length ; $i ++ ) {
578
580
if ($ShouldBreakLine -or $OutputLine.Length -ge 40 ) {
579
581
$OutputLine += " ^"
580
582
Write-Output $OutputLine
581
583
$OutputLine = " "
582
584
}
583
585
584
- $Arg = $Args [$i ]
586
+ $Arg = $ExecutableArgs [$i ]
585
587
if ($Arg.Contains (" " )) {
586
588
$OutputLine += " `" $Arg `" "
587
589
} else {
@@ -594,32 +596,34 @@ function Invoke-Program() {
594
596
595
597
if ($OutNull ) {
596
598
$OutputLine += " > nul"
597
- } elseif ($OutFile ) {
598
- $OutputLine += " > `" $OutFile `" "
599
- }
600
- if ($ErrorFile ) {
601
- $ OutputLine += " 2> `" $ErrorFile `" "
599
+ } elseif ($Silent ) {
600
+ $OutputLine += " *> nul "
601
+ } else {
602
+ if ($OutFile ) { $OutputLine += " > `" $OutFile `" " }
603
+ if ( $ErrorFile ) { $ OutputLine += " 2> `" $ErrorFile `" " }
602
604
}
603
605
604
606
Write-Output $OutputLine
605
607
} else {
606
608
if ($OutNull ) {
607
- & $Executable @Args | Out-Null
609
+ & $Executable @ExecutableArgs | Out-Null
610
+ } elseif ($Silent ) {
611
+ & $Executable @ExecutableArgs * > $null
608
612
} elseif ($OutFile -and $ErrorFile ) {
609
- & $Executable @Args > $OutFile 2> $ErrorFile
613
+ & $Executable @ExecutableArgs > $OutFile 2> $ErrorFile
610
614
} elseif ($OutFile ) {
611
- & $Executable @Args > $OutFile
615
+ & $Executable @ExecutableArgs > $OutFile
612
616
} elseif ($ErrorFile ) {
613
- & $Executable @Args 2> $ErrorFile
617
+ & $Executable @ExecutableArgs 2> $ErrorFile
614
618
} else {
615
- & $Executable @Args
619
+ & $Executable @ExecutableArgs
616
620
}
617
621
618
622
if ($LastExitCode -ne 0 ) {
619
623
$ErrorMessage = " Error: $ ( [IO.Path ]::GetFileName($Executable )) exited with code $ ( $LastExitCode ) .`n "
620
624
621
625
$ErrorMessage += " Invocation:`n "
622
- $ErrorMessage += " $Executable $Args `n "
626
+ $ErrorMessage += " $Executable $ExecutableArgs `n "
623
627
624
628
$ErrorMessage += " Call stack:`n "
625
629
foreach ($Frame in @ (Get-PSCallStack )) {
@@ -827,7 +831,7 @@ function Fetch-Dependencies {
827
831
828
832
function Install-PythonWheel ([string ] $ModuleName , [string ] $WheelFile , [string ] $WheelURL , [string ] $WheelHash ) {
829
833
try {
830
- Invoke-Program " $ ( Get-PythonExecutable ) " - c " import $ModuleName " * > $null
834
+ Invoke-Program - Silent " $ ( Get-PythonExecutable ) " - c " import $ModuleName "
831
835
} catch {
832
836
DownloadAndVerify $WheelURL " $BinaryCache \python\$WheelFile " $WheelHash
833
837
Write-Output " Installing '$WheelFile ' ..."
@@ -838,7 +842,7 @@ function Fetch-Dependencies {
838
842
function Install-PythonModules () {
839
843
# First ensure pip is installed, else bootstrap it
840
844
try {
841
- Invoke-Program " $ ( Get-PythonExecutable ) " - m pip * > $null
845
+ Invoke-Program - Silent " $ ( Get-PythonExecutable ) " - m pip
842
846
} catch {
843
847
Write-Output " Installing pip ..."
844
848
Invoke-Program - OutNull " $ ( Get-PythonExecutable ) " ' -I' - m ensurepip - U -- default- pip
0 commit comments