From d6c7fc8f239166b37774cf61e835fdc352f06654 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Thu, 23 Jun 2016 13:03:24 -0500 Subject: [PATCH] (GH-808) Allow silent args as array Some packages have passed silent arguments as an array. Allow specifying it as a string array and then join the arguments together. --- .../helpers/functions/Install-ChocolateyInstallPackage.ps1 | 4 +++- .../helpers/functions/Install-ChocolateyPackage.ps1 | 3 ++- .../helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 | 3 ++- .../helpers/functions/Uninstall-ChocolateyPackage.ps1 | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 index 5cdea6f164..be3f7901a0 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 @@ -143,13 +143,15 @@ param( [parameter(Mandatory=$true, Position=0)][string] $packageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType","installType")][string] $fileType = 'exe', - [parameter(Mandatory=$false, Position=2)][string] $silentArgs = '', + [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '', [parameter(Mandatory=$true, Position=3)][string] $file, [parameter(Mandatory=$false)] $validExitCodes = @(0), [parameter(Mandatory=$false)] [alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) + [string]$silentArgs = $silentArgs -join ' ' + Write-Debug "Running 'Install-ChocolateyInstallPackage' for $packageName with file:`'$file`', args: `'$silentArgs`', fileType: `'$fileType`', validExitCodes: `'$validExitCodes`', useOnlyPackageSilentArguments: '$($useOnlyPackageSilentArguments.IsPresent)'"; $installMessage = "Installing $packageName..." Write-Host $installMessage diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index c38e4d85c4..312a78a6e0 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -216,7 +216,7 @@ param( [parameter(Mandatory=$true, Position=0)][string] $packageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType","installType")][string] $fileType = 'exe', - [parameter(Mandatory=$false, Position=2)][string] $silentArgs = '', + [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '', [parameter(Mandatory=$false, Position=3)][string] $url = '', [parameter(Mandatory=$false, Position=4)] [alias("url64")][string] $url64bit = '', @@ -230,6 +230,7 @@ param( [alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) + [string]$silentArgs = $silentArgs -join ' ' Write-Debug "Running 'Install-ChocolateyPackage' for $packageName with url:`'$url`', args: `'$silentArgs`', fileType: `'$fileType`', url64bit: `'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`', validExitCodes: `'$validExitCodes`' "; diff --git a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 index db4b04d44a..6b307ca82c 100644 --- a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 +++ b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 @@ -78,13 +78,14 @@ Install-ChocolateyPackage Install-ChocolateyInstallPackage #> param( - [parameter(Mandatory=$false, Position=0)][string] $statements, + [parameter(Mandatory=$false, Position=0)][string[]] $statements, [parameter(Mandatory=$false, Position=1)][string] $exeToRun = 'powershell', [parameter(Mandatory=$false)][switch] $minimized, [parameter(Mandatory=$false)][switch] $noSleep, [parameter(Mandatory=$false)] $validExitCodes = @(0), [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) + [statements]$statements = $statements -join ' ' Write-Debug "Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:`'$exeToRun`', statements: `'$statements`' "; $wrappedStatements = $statements diff --git a/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 index beac91be1b..ed4c9db8d6 100644 --- a/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPackage.ps1 @@ -105,11 +105,13 @@ param( [parameter(Mandatory=$true, Position=0)][string] $packageName, [parameter(Mandatory=$false, Position=1)] [alias("installerType")][string] $fileType = 'exe', - [parameter(Mandatory=$false, Position=2)][string] $silentArgs = '', + [parameter(Mandatory=$false, Position=2)][string[]] $silentArgs = '', [parameter(Mandatory=$false, Position=3)][string] $file, [parameter(Mandatory=$false)] $validExitCodes = @(0), [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) + [string]$silentArgs = $silentArgs -join ' ' + Write-Debug "Running 'Uninstall-ChocolateyPackage' for $packageName with fileType:`'$fileType`', silentArgs: `'$silentArgs`', file: `'$file`'"; $installMessage = "Uninstalling $packageName..."