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

fix passing null parameters to Find-WinGetPackage #2092

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,65 +102,78 @@ Function Install-WinGetPackage
)
BEGIN
{
[string[]] $WinGetArgs = "Install"
$WinGetFindArgs = @{}
[string[]] $WinGetInstallArgs = "Install"
IF($PSBoundParameters.ContainsKey('Filter')){
IF($Local) {
$WinGetArgs += "--Manifest"
$WinGetInstallArgs += "--Manifest"
}
$WinGetArgs += $Filter
$WinGetInstallArgs += $Filter
}
IF($PSBoundParameters.ContainsKey('Filter')){
IF($Local) {
$WinGetInstallArgs += "--Manifest"
}
$WinGetInstallArgs += $Filter
$WinGetFindArgs.Add('Filter', $Filter)
}
IF($PSBoundParameters.ContainsKey('Name')){
$WinGetArgs += "--Name", $Name
$WinGetInstallArgs += "--Name", $Name
$WinGetFindArgs.Add('Name', $Name)
}
IF($PSBoundParameters.ContainsKey('Id')){
$WinGetArgs += "--Id", $Id
$WinGetInstallArgs += "--Id", $Id
$WinGetFindArgs.Add('Id', $Id)
}
IF($PSBoundParameters.ContainsKey('Moniker')){
$WinGetArgs += "--Moniker", $Moniker
$WinGetInstallArgs += "--Moniker", $Moniker
$WinGetFindArgs.Add('Moniker', $Moniker)
}
IF($PSBoundParameters.ContainsKey('Source')){
$WinGetArgs += "--Source", $Source
$WinGetInstallArgs += "--Source", $Source
$WinGetFindArgs.Add('Source', $Source)
}
IF($PSBoundParameters.ContainsKey('Scope')){
$WinGetArgs += "--Scope", $Scope
$WinGetInstallArgs += "--Scope", $Scope
}
IF($Interactive){
$WinGetArgs += "--Interactive"
$WinGetInstallArgs += "--Interactive"
}
IF($Silent){
$WinGetArgs += "--Silent"
$WinGetInstallArgs += "--Silent"
}
IF($PSBoundParameters.ContainsKey('Locale')){
$WinGetArgs += "--locale", $Locale
$WinGetInstallArgs += "--locale", $Locale
}
if($PSBoundParameters.ContainsKey('Version')){
$WinGetArgs += "--Version", $Version
$WinGetInstallArgs += "--Version", $Version
}
if($Exact){
$WinGetArgs += "--Exact"
$WinGetInstallArgs += "--Exact"
$WinGetFindArgs.Add('Exact', $true)
}
if($PSBoundParameters.ContainsKey('Log')){
$WinGetArgs += "--Log", $Log
$WinGetInstallArgs += "--Log", $Log
}
if($PSBoundParameters.ContainsKey('Override')){
$WinGetArgs += "--override", $Override
$WinGetInstallArgs += "--override", $Override
}
if($PSBoundParameters.ContainsKey('Location')){
$WinGetArgs += "--Location", $Location
$WinGetInstallArgs += "--Location", $Location
}
if($Force){
$WinGetArgs += "--Force"
$WinGetInstallArgs += "--Force"
}
}
PROCESS
{
## Exact, ID and Source - Talk with Demitrius tomorrow to better understand this.
IF(!$Local) {
$Result = Find-WinGetPackage -Filter $Filter -Name $Name -Id $Id -Moniker $Moniker -Tag $Tag -Command $Command -Source $Source
$Result = Find-WinGetPackage @WinGetFindArgs
}

if($Result.count -eq 1 -or $Local) {
& "WinGet" $WingetArgs
& "WinGet" $WinGetInstallArgs
$Result = ""
}
elseif($Result.count -lt 1){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ PowerShellVersion = '5.1'
# NestedModules = @()

# Functions to export from this module, for best performance, do not use wild cards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @("Get-WinGetPackage", "Get-WinGetSource", "Get-WinGetVersion", "Add-WinGetSource")
FunctionsToExport = '*'

# Cmdlets to export from this module, for best performance, do not use wild cards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = @()
Expand Down