Skip to content

Commit

Permalink
add exit status codes to query a single package
Browse files Browse the repository at this point in the history
if a single package version is queried at the cli in cmd or posh
then a 0 error status code is returned if the package is present on
the system or a 1 status code if 'not found'
  • Loading branch information
rismoney committed Apr 19, 2013
1 parent 51cde55 commit f8ec947
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/functions/Chocolatey-Version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,10 @@ param(
$versionsObj
}
}

# exit error 1 if querying a single package, no version returned, and not called from another function (ie cup)
$commandType=((Get-Variable -Name MyInvocation -Scope 1 -ValueOnly).MyCommand).CommandType
if ($packages.count -eq 1 -and $versionFound -eq 'no version' -and $commandType -ne 'Function') {
throw ""
}
}

0 comments on commit f8ec947

Please sign in to comment.