Fixed choco outdated command to not use $LASTEXITCODE and instead check if NULL

This commit is contained in:
Dan Franciscus
2019-06-05 10:04:31 -04:00
parent 1e0b6fde5a
commit fcc67aa9c5
3 changed files with 13 additions and 26 deletions

View File

@@ -1,19 +1,11 @@
# Chocolatey-tools Release History # Chocolatey-tools Release History
## Version Number - Release Date ## 0.4.3 - 6/5/2019
### Fixed ### Fixed
* First item fixed * Get-ChocoOutdatedPackages was failing due to change in $LASTEXITCODE handling in latest
Chocolatey version (0.10.15)
* Second item fixed * Second item fixed
### Added
* New item added
* Another new item added
### Changed
* Feature changed
* Tests added

View File

@@ -12,7 +12,7 @@
RootModule = 'Chocolatey-tools.psm1' RootModule = 'Chocolatey-tools.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '0.4.2' ModuleVersion = '0.4.3'
# Supported PSEditions # Supported PSEditions
# CompatiblePSEditions = @() # CompatiblePSEditions = @()

View File

@@ -19,13 +19,8 @@ function Get-ChocoOutdatedPackages {
) )
Write-Verbose "Getting local outdated packages" Write-Verbose "Getting local outdated packages"
$OutdatedPackages = (choco outdated -r --ignore-pinned --ignore-unfound --timeout=60) $OutdatedPackages = (choco outdated -r --ignore-pinned --ignore-unfound --timeout=60)
if ($LASTEXITCODE -eq 1){ if (!($OutdatedPackages){
Write-Verbose -Message 'Error getting outdated packages' Write-Verbose -Message 'No outdated packages'
$OutdatedPackages
Exit
}
if ($LASTEXITCODE -eq 0){
Write-Verbose -Message 'No new packages available. Exiting'
Exit Exit
} }
else { else {