Refactor winget check for rare issue

This commit is contained in:
Manuel Thalmann 2024-08-16 15:04:37 +02:00
parent 9f43dbf0e8
commit 0d2c28e74a

View file

@ -79,10 +79,14 @@ function Test-Command {
Checks whether `winget` is working properly. Checks whether `winget` is working properly.
#> #>
function Test-Winget { function Test-Winget {
(Test-Command winget) -and -not ( (Test-Command winget) -and (
[System.Linq.Enumerable]::Any( & {
[string[]](winget source update winget), $output = winget source update winget;
[System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; }));
$? -and -not ([System.Linq.Enumerable]::Any(
[string[]]($output),
[System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; }));
});
} }
<# <#