Skip to content

Commit

Permalink
(GH-1060) Add BeforeInstall parameter to Install-ChocolateyPackage.ps1
Browse files Browse the repository at this point in the history
- Add a ScriptBlock parameter `BeforeInstall` to Install-ChocolateyPackage.ps1. If supplied, the script block is called after download but before install.
  • Loading branch information
flcdrg authored and gep13 committed Apr 16, 2021
1 parent a3e6f56 commit 8be88e0
Showing 1 changed file with 13 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,8 @@ 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 +414,10 @@ param(
-GetOriginalFileName
}

if ($beforeInstall) {
& $beforeInstall
}

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

0 comments on commit 8be88e0

Please sign in to comment.