Skip to content

Commit

Permalink
(maint) Change formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gep13 committed May 12, 2021
1 parent 6580737 commit 79098d6
Showing 1 changed file with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# limitations under the License.

function Install-ChocolateyInstallPackage {
<#
<#
.SYNOPSIS
**NOTE:** Administrative Access Required.
Expand Down Expand Up @@ -210,18 +210,18 @@ Get-UninstallRegistryKey
.LINK
Start-ChocolateyProcessAsAdmin
#>
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 = '',
[alias("fileFullPath")][parameter(Mandatory=$false, Position=3)][string] $file,
[alias("fileFullPath64")][parameter(Mandatory=$false)][string] $file64,
[parameter(Mandatory=$false)] $validExitCodes = @(0),
[parameter(Mandatory=$false)]
[alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)
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 = '',
[alias("fileFullPath")][parameter(Mandatory = $false, Position = 3)][string] $file,
[alias("fileFullPath64")][parameter(Mandatory = $false)][string] $file64,
[parameter(Mandatory = $false)] $validExitCodes = @(0),
[parameter(Mandatory = $false)]
[alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)
[string]$silentArgs = $silentArgs -join ' '

Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters
Expand All @@ -231,7 +231,8 @@ param(
if ((Get-ProcessorBits 32) -or $env:ChocolateyForceX86 -eq 'true') {
if (!$file) { throw "32-bit installation is not supported for $packageName"; }
if ($file64) { $bitnessMessage = '32-bit '; }
} elseif ($file64) {
}
elseif ($file64) {
$fileFullPath = $file64
$bitnessMessage = '64-bit '
}
Expand Down Expand Up @@ -292,31 +293,34 @@ Pro / Business supports a single, ubiquitous install directory option.
if ($env:ChocolateyInstall -and $ignoreFile -match [System.Text.RegularExpressions.Regex]::Escape($env:ChocolateyInstall)) {
try {
'' | out-file $ignoreFile
} catch {
}
catch {
Write-Warning "Unable to generate `'$ignoreFile`'"
}
}

$workingDirectory = Get-Location -PSProvider "FileSystem"
try {
$workingDirectory = [System.IO.Path]::GetDirectoryName($fileFullPath)
} catch {
}
catch {
Write-Warning "Unable to set the working directory for installer to location of '$fileFullPath'"
$workingDirectory = $env:TEMP
}

try {
# make sure any logging folder exists
$pattern = "(?:['`"])([a-zA-Z]\:\\[^'`"]+)(?:[`"'])|([a-zA-Z]\:\\[\S]+)"
$silentArgs, $additionalInstallArgs | %{ Select-String $pattern -input $_ -AllMatches } |
% { $_.Matches } | % {
$argDirectory = $_.Groups[1]
if ($argDirectory -eq $null -or $argDirectory -eq '') { continue }
$argDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::GetDirectoryName($argDirectory))
Write-Debug "Ensuring '$argDirectory' exists"
if (![System.IO.Directory]::Exists($argDirectory)) { [System.IO.Directory]::CreateDirectory($argDirectory) | Out-Null }
}
} catch {
$silentArgs, $additionalInstallArgs | % { Select-String $pattern -input $_ -AllMatches } |
% { $_.Matches } | % {
$argDirectory = $_.Groups[1]
if ($argDirectory -eq $null -or $argDirectory -eq '') { continue }
$argDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::GetDirectoryName($argDirectory))
Write-Debug "Ensuring '$argDirectory' exists"
if (![System.IO.Directory]::Exists($argDirectory)) { [System.IO.Directory]::CreateDirectory($argDirectory) | Out-Null }
}
}
catch {
Write-Debug "Error ensuring directories exist - $($_.Exception.Message)"
}

Expand All @@ -325,7 +329,8 @@ Pro / Business supports a single, ubiquitous install directory option.
if ($overrideArguments) {
Write-Host "Overriding package arguments with '$additionalInstallArgs' (replacing '$silentArgs')";
$msiArgs = "$msiArgs $additionalInstallArgs";
} else {
}
else {
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs";
}

Expand All @@ -336,16 +341,18 @@ Pro / Business supports a single, ubiquitous install directory option.
if ($overrideArguments) {
Write-Host "Overriding package arguments with '$additionalInstallArgs' (replacing '$silentArgs')";
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
} else {
}
else {
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$silentArgs $additionalInstallArgs" $fileFullPath -validExitCodes $validExitCodes -workingDirectory $workingDirectory
}
}

if($fileType -like 'msu') {
if ($fileType -like 'msu') {
if ($overrideArguments) {
Write-Host "Overriding package arguments with '$additionalInstallArgs' (replacing '$silentArgs')";
$msuArgs = "`"$fileFullPath`" $additionalInstallArgs"
} else {
}
else {
$msuArgs = "`"$fileFullPath`" $silentArgs $additionalInstallArgs"
}
$env:ChocolateyExitCode = Start-ChocolateyProcessAsAdmin "$msuArgs" "$($env:SystemRoot)\System32\wusa.exe" -validExitCodes $validExitCodes -workingDirectory $workingDirectory
Expand Down

0 comments on commit 79098d6

Please sign in to comment.