Skip to content

Commit 43ccb7f

Browse files
Add Chocolatey v2.0 compatibility (#191)
* removed "-l" switch from "choco list" command for Chocolatey 2.0 compatibility Running `choco list -l` on Chocolatey 2.0.0 produces the following error: ```Invalid argument -l. This argument has been removed from the list command and cannot be used.``` Removing the `-l` switch resolves the error and winfetch works properly again. * handle "choco list" syntax for chocolatey 1.x and 2.x
1 parent 9cc0ebe commit 43ccb7f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

winfetch.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,9 @@ function info_pkgs {
872872
}
873873

874874
if ("choco" -in $ShowPkgs -and (Get-Command -Name choco -ErrorAction Ignore)) {
875-
$chocopkg = (& choco list -l)[-1].Split(' ')[0] - 1
875+
$chocopkg = Invoke-Expression $(
876+
"(& choco list" + $(if([version](& choco --version).Split('-')[0]`
877+
-lt [version]'2.0.0'){" --local-only"}) + ")[-1].Split(' ')[0] - 1")
876878

877879
if ($chocopkg) {
878880
$pkgs += "$chocopkg (choco)"

0 commit comments

Comments
 (0)