diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index c4b47da8..a45df67b 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -64,7 +64,7 @@ $null = New-Module { Install-Module -AcceptLicense -Force PSWindowsUpdate; }; - if (-not (Test-Command winget)) { + if (-not (Test-Winget)) { . "$PSScriptRoot/../Software/winget/Manage.ps1"; continue; } diff --git a/scripts/Windows/Scripts/SoftwareManagement.ps1 b/scripts/Windows/Scripts/SoftwareManagement.ps1 index c850fa67..95a44a2f 100644 --- a/scripts/Windows/Scripts/SoftwareManagement.ps1 +++ b/scripts/Windows/Scripts/SoftwareManagement.ps1 @@ -58,6 +58,17 @@ function Test-Command { [bool] (Get-Command $Name -ErrorAction SilentlyContinue); } +<# + .SYNOPSIS + 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"; })); +} + <# .SYNOPSIS Checks whether a package with the specified name is installed.