From db9f86992b20a80ba22d8848998dd980dddd2afb Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 16 Aug 2024 15:04:37 +0200 Subject: [PATCH] Refactor `winget` check for rare issue --- scripts/Common/Scripts/SoftwareManagement.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/Common/Scripts/SoftwareManagement.ps1 b/scripts/Common/Scripts/SoftwareManagement.ps1 index deb4afea..51cb6a21 100644 --- a/scripts/Common/Scripts/SoftwareManagement.ps1 +++ b/scripts/Common/Scripts/SoftwareManagement.ps1 @@ -79,10 +79,14 @@ function Test-Command { Checks whether `winget` is working properly. #> function Test-Winget { - (Test-Command winget) -and -not ( - [System.Linq.Enumerable]::Any( - [string[]](winget source update winget), - [System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; })); + (Test-Command winget) -and ( + & { + $output = winget source update winget; + + $? -and -not ([System.Linq.Enumerable]::Any( + [string[]]($output), + [System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; })); + }); } <#