Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-87) Moved to using limited output. #88

Closed
wants to merge 1 commit into from
Closed

(GH-87) Moved to using limited output. #88

wants to merge 1 commit into from

Conversation

lukegriffith
Copy link
Contributor

@lukegriffith lukegriffith commented Jul 10, 2017

Old implementation caused promotional message, and chocolatey banner to get mixed into the works. If upgrading Chocolatey, cause problems as the version caught is a string with "vX.X.X" and in the where clause is attempted to be converted to a .net version type.

Limiting the output reduces it to only the packages, leaving out any banners.

Spent a while thinking of how to test this, as point 5 states - but nothing could come to mind without mocking the call to choco and writing its own response, at least from what I can think of.

An example of the fixes below

<#

PS C:\Users\lg\Documents\Git\cChoco> choco list -lo
Chocolatey v0.10.7
chocolatey 0.10.7
erlang 19.3
rabbitmq 3.6.10
3 packages installed.


#>


 function Get-ChocoInstalledPackage {
    $res = choco list -lo | ForEach-Object {
        $Obj = $_ -split '\s'
        [pscustomobject]@{
            'Name'    = $Obj[0]
            'Version' = $Obj[1]     
        }
    }
    Return $res
    

 }

 Get-ChocoInstalledPackage

 <#

 Name       Version 
----       ------- 
Chocolatey v0.10.7 
chocolatey 0.10.7  
erlang     19.3    
rabbitmq   3.6.10  
3          packages


 #>

 function Get-ChocoInstalledPackage {

 Return (choco list -lo -r | ConvertFrom-Csv -Header 'Name', 'Version' -Delimiter "|")

 }

 Get-ChocoInstalledPackage

 <#

 Name       Version
----       -------
chocolatey 0.10.7 
erlang     19.3   
rabbitmq   3.6.10

 #>

Closes #87.

Copy link
Member

@ferventcoder ferventcoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good to me. Less code to accomplish the same thing as well!

@ferventcoder ferventcoder changed the title Moved to using limited output. (GH-87) Moved to using limited output. Jul 14, 2017
@ferventcoder
Copy link
Member

Merged into development at c7d4976

@ferventcoder
Copy link
Member

Thank you for your contribution!

@lukegriffith lukegriffith deleted the lg-dev branch September 10, 2019 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implementation of Get-ChocoInstalledPackage fails when using Chocolatey as a package
2 participants