Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
Merge branch 'avdv/wait-for-process' into stable
Browse files Browse the repository at this point in the history
* avdv/wait-for-process:
  (GH-256) cpack/cpush always return 0 exit code even w/errors
  (maint) formatting
  (GH-516) Guard all Wait-Process if posh v3+
  Fix bogus error message with error code from 7za amiss
  • Loading branch information
ferventcoder committed Jul 11, 2014
2 parents 981b963 + 3ff8ba0 commit b354494
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/functions/Chocolatey-Pack.ps1
Expand Up @@ -10,15 +10,15 @@ param(

Write-Host "Calling `'$nugetExe $packageArgs`'."

Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Write-Host $line
}
$errors = Get-Content $errorLogFile
if ($errors -ne '') {
Write-Host $errors -BackgroundColor Red -ForegroundColor White
#throw $errors
if ($process.ExitCode -ne 0) {
throw $errors
}
}
8 changes: 4 additions & 4 deletions src/functions/Chocolatey-Push.ps1
Expand Up @@ -17,15 +17,15 @@ param(

Write-Host "Calling `'$nugetExe $packageArgs`'. This may take a few minutes. Please wait for the command to finish." -ForegroundColor $Note -BackgroundColor Black

Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile
$process = Start-Process $nugetExe -ArgumentList $packageArgs -NoNewWindow -Wait -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

$nugetOutput = Get-Content $logFile -Encoding Ascii
foreach ($line in $nugetOutput) {
Write-Host $line -ForegroundColor $Note -BackgroundColor Black
}
$errors = Get-Content $errorLogFile
if ($errors -ne '') {
Write-Host $errors -BackgroundColor Red -ForegroundColor White
#throw $errors
if ($process.ExitCode -ne 0) {
throw $errors
}
}
21 changes: 11 additions & 10 deletions src/functions/Chocolatey-Python.ps1
@@ -1,7 +1,7 @@
function Chocolatey-Python {
param(
[string] $packageName,
[string] $version ='',
[string] $packageName,
[string] $version ='',
[string] $installerArguments =''
)

Expand All @@ -14,19 +14,19 @@ param(
}

Chocolatey-InstallIfMissing 'easy.install'

Write-Host "Chocolatey (v$chocVer) is installing $packageName and dependencies (using Python). By installing you accept the license for $packageName and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black


$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyPythonInstall.log';
Append-Log $chocoInstallLog

$packageArgs = "/c easy_install $packageName"
if ($version -notlike '') {
Write-Debug "Adding version arguments `'$version`'"
$packageArgs = "/c easy_install $packageName==$version";
}

if ($installerArguments -ne '') {
Write-Debug "Adding installerArguments `'$installerArguments`'"
$packageArgs = "$packageArgs $installerArguments";
Expand All @@ -36,13 +36,14 @@ param(
#& cmd.exe $packagesArgs | Tee-Object -FilePath $chocoInstallLog

Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized

$process = Start-Process -FilePath "$($env:windir)\System32\WindowsPowerShell\v1.0\powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy unrestricted -Command `"cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`'`"" -Wait -WindowStyle Minimized -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}

Write-Host "Finished installing `'$packageName`' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure." -ForegroundColor $RunNote -BackgroundColor Black
}
}
1 change: 1 addition & 0 deletions src/helpers/functions/Get-CheckSumValid.ps1
Expand Up @@ -20,6 +20,7 @@ param(

Write-Debug "Calling command [`'$checksumExe`' -c$checksum `"$file`"] to retrieve checksum"
$process = Start-Process "$checksumExe" -ArgumentList " -c=`"$checksum`" -t=`"$checksumType`" -f=`"$file`"" -Wait -WindowStyle Hidden -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $process }

Write-Debug "`'$checksumExe`' exited with $($process.ExitCode)"

Expand Down
1 change: 1 addition & 0 deletions src/helpers/functions/Get-ChocolateyUnzip.ps1
Expand Up @@ -80,6 +80,7 @@ param(
$unzipOps = {
param($7zip, $destination, $fileFullPath, [ref]$exitCodeRef)
$p = Start-Process $7zip -ArgumentList "x -o`"$destination`" -y `"$fileFullPath`"" -Wait -WindowStyle Hidden -PassThru
if ($host.Version.Major -ge 3) { Wait-Process -InputObject $p }
$exitCodeRef.Value = $p.ExitCode
}

Expand Down

0 comments on commit b354494

Please sign in to comment.