From 4c3cf9c6a548322905b1afe20b8bbd5e47244d6f Mon Sep 17 00:00:00 2001 From: David Gardiner Date: Fri, 27 Oct 2017 18:12:51 +1030 Subject: [PATCH] (GH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1 - Add a ScriptBlock parameter `BeforeInstall` to Install-ChocolateyPackage.ps1. If supplied, the script block is called after download but before install. --- .../helpers/functions/Install-ChocolateyPackage.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 9131d0f2b3..030c198de1 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -220,6 +220,13 @@ functionality (see links). .PARAMETER IgnoredArguments Allows splatting with arguments that do not apply. Do not use directly. +.PARAMETER BeforeInstall Script +Specifies the commands to run after download has completed but before install steps have begun. +Available in 0.10.16+. + +Use this for starting an auxilary process such as AutoHotkey, so that any timeouts are not +affected by the time to download. + .EXAMPLE > $packageName= 'bob' @@ -359,6 +366,7 @@ param( [parameter(Mandatory=$false)] [alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false, [parameter(Mandatory=$false)][switch]$useOriginalLocation, + [parameter(Mandatory=$false)][scriptblock] $beforeInstall, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) [string]$silentArgs = $silentArgs -join ' ' @@ -405,6 +413,10 @@ param( -GetOriginalFileName } + if ($beforeInstall) { + & $beforeInstall + } + Install-ChocolateyInstallPackage -PackageName $packageName ` -FileType $fileType ` -SilentArgs $silentArgs `