From df4935133d63e95d2dab8f748b58dce345b30608 Mon Sep 17 00:00:00 2001 From: Cowan Date: Sun, 29 Dec 2019 17:34:11 -0800 Subject: [PATCH 1/2] (GH-1716) Added default parameters for package name Set default value of packageName to $env:chocolateyPackageName for Install-ChocolateyZipPackage and Get-ChocolateyUnzip. This is usually the value used as default in install scripts, so this can reduce the number of necessary parameters specified. --- .../helpers/functions/Get-ChocolateyUnzip.ps1 | 2 +- .../helpers/functions/Install-ChocolateyZipPackage.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 index 06763379b2..337186fa21 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyUnzip.ps1 @@ -90,7 +90,7 @@ param( [alias("file")][parameter(Mandatory=$false, Position=0)][string] $fileFullPath, [parameter(Mandatory=$true, Position=1)][string] $destination, [parameter(Mandatory=$false, Position=2)][string] $specificFolder, - [parameter(Mandatory=$false, Position=3)][string] $packageName, + [parameter(Mandatory=$false, Position=3)][string] $packageName = $env:chocolateyPackageName, [alias("file64")][parameter(Mandatory=$false)][string] $fileFullPath64, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 index d6aad516c7..7cfc8288a9 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyZipPackage.ps1 @@ -173,7 +173,7 @@ Get-ChocolateyWebFile Get-ChocolateyUnzip #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$false, Position=1)][string] $url = '', [parameter(Mandatory=$true, Position=2)] [alias("destination")][string] $unzipLocation, From 330eb902968ad2f0242657885c836feaca243a9a Mon Sep 17 00:00:00 2001 From: Cowan Cumming Date: Sat, 4 Jan 2020 15:38:50 -0800 Subject: [PATCH 2/2] Added default value to packageName on more scripts. There were six more scripts using a packageName variable which should have access to the chocolateyPackageName environment variable. This should be used the default value for the packageName for the scripts so that we can reduce the number of necessary arguments. --- .../helpers/functions/Get-ChocolateyWebFile.ps1 | 2 +- .../helpers/functions/Install-ChocolateyInstallPackage.ps1 | 2 +- .../helpers/functions/Install-ChocolateyPackage.ps1 | 2 +- .../helpers/functions/Install-ChocolateyVsixPackage.ps1 | 2 +- .../helpers/functions/UnInstall-ChocolateyZipPackage.ps1 | 2 +- .../helpers/functions/Uninstall-ChocolateyPackage.ps1 | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 index 246cef1248..059e833bd4 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 @@ -188,7 +188,7 @@ Get-WebFileName Get-FtpFile #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$true, Position=1)][string] $fileFullPath, [parameter(Mandatory=$false, Position=2)][string] $url = '', [parameter(Mandatory=$false, Position=3)] diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 index c17bc6c266..d9ba5ed83e 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 @@ -211,7 +211,7 @@ Get-UninstallRegistryKey Start-ChocolateyProcessAsAdmin #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType","installType")][string] $fileType = 'exe', [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '', diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index d5ac643bcf..23e4c6aff0 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -341,7 +341,7 @@ Get-UninstallRegistryKey Install-ChocolateyZipPackage #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType","installType")][string] $fileType = 'exe', [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '', diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 index f86866c591..318e06d4e3 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyVsixPackage.ps1 @@ -137,7 +137,7 @@ Install-ChocolateyInstallPackage Install-ChocolateyZipPackage #> param( - [alias("name")][parameter(Mandatory=$true, Position=0)][string] $packageName, + [alias("name")][parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [alias("url")][parameter(Mandatory=$false, Position=1)][string] $vsixUrl, [alias("visualStudioVersion")][parameter(Mandatory=$false, Position=2)][int] $vsVersion = 0, [parameter(Mandatory=$false)][string] $checksum = '', diff --git a/src/chocolatey.resources/helpers/functions/UnInstall-ChocolateyZipPackage.ps1 b/src/chocolatey.resources/helpers/functions/UnInstall-ChocolateyZipPackage.ps1 index dd4481a90b..5d5ac8b1ab 100644 --- a/src/chocolatey.resources/helpers/functions/UnInstall-ChocolateyZipPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/UnInstall-ChocolateyZipPackage.ps1 @@ -56,7 +56,7 @@ Install-ChocolateyZipPackage Uninstall-ChocolateyPackage #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$true, Position=1)][string] $zipFileName, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) diff --git a/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 index 126ec54c22..8040a39d7a 100644 --- a/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 @@ -107,7 +107,7 @@ Uninstall-ChocolateyZipPackage Get-UninstallRegistryKey #> param( - [parameter(Mandatory=$true, Position=0)][string] $packageName, + [parameter(Mandatory=$false, Position=0)][string] $packageName = $env:chocolateyPackageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType")][string] $fileType = 'exe', [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '',