Skip to content

Commit

Permalink
(GH-758) Ensure log path exists
Browse files Browse the repository at this point in the history
Ensure the log directory exists by attempting to create it,
failing silently if not able to create the directory.
Windows Installer in particular will fail when the log directory
doesn't already exist.
  • Loading branch information
ferventcoder committed Jun 19, 2016
1 parent ae2e857 commit 1e18060
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ Pro / Business supports a single, ubiquitous install directory option.
$silentArgs = $silentArgs -replace '\\chocolatey\\chocolatey\\', '\chocolatey\'
$additionalInstallArgs = $additionalInstallArgs -replace '\\chocolatey\\chocolatey\\', '\chocolatey\'

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 {
Write-Debug "Error ensuring directories exist - $($_.Exception.Message)"
}

if ($fileType -like 'msi') {
$msiArgs = "/i `"$file`""
if ($overrideArguments) {
Expand Down

0 comments on commit 1e18060

Please sign in to comment.