Skip to content

Commit

Permalink
Merge pull request chocolatey#1436 from flcdrg/BeforeInstallScriptBlock
Browse files Browse the repository at this point in the history
(chocolateyGH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1
  • Loading branch information
gep13 authored Apr 16, 2021
2 parents a3e6f56 + 4c3cf9c commit deda8fe
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 ' '
Expand Down Expand Up @@ -405,6 +413,10 @@ param(
-GetOriginalFileName
}

if ($beforeInstall) {
& $beforeInstall
}

Install-ChocolateyInstallPackage -PackageName $packageName `
-FileType $fileType `
-SilentArgs $silentArgs `
Expand Down

0 comments on commit deda8fe

Please sign in to comment.