Skip to content

Commit

Permalink
ChocolateyInstall env var. patch, cherry picked from PR chocolatey#178
Browse files Browse the repository at this point in the history
  • Loading branch information
bozho committed Mar 6, 2024
1 parent f583fee commit caccfa6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ function Get-ChocoInstalledPackage {
[switch]$NoCache
)

if ([string]::IsNullOrEmpty($env:ChocolateyInstall))
{
$env:ChocolateyInstall = [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine')
}

$ChocoInstallLP = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache'
if ( -not (Test-Path $ChocoInstallLP)){
New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null
Expand Down Expand Up @@ -532,6 +537,12 @@ function Get-ChocoVersion {
[switch]$Purge,
[switch]$NoCache
)

if ([string]::IsNullOrEmpty($env:ChocolateyInstall))
{
$env:ChocolateyInstall = [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine')
}

$chocoInstallCache = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache'
if ( -not (Test-Path $chocoInstallCache)){
New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null
Expand Down

0 comments on commit caccfa6

Please sign in to comment.