Skip to content

Commit caccfa6

Browse files
committed
ChocolateyInstall env var. patch, cherry picked from PR chocolatey#178
1 parent f583fee commit caccfa6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@ function Get-ChocoInstalledPackage {
501501
[switch]$NoCache
502502
)
503503

504+
if ([string]::IsNullOrEmpty($env:ChocolateyInstall))
505+
{
506+
$env:ChocolateyInstall = [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine')
507+
}
508+
504509
$ChocoInstallLP = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache'
505510
if ( -not (Test-Path $ChocoInstallLP)){
506511
New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null
@@ -532,6 +537,12 @@ function Get-ChocoVersion {
532537
[switch]$Purge,
533538
[switch]$NoCache
534539
)
540+
541+
if ([string]::IsNullOrEmpty($env:ChocolateyInstall))
542+
{
543+
$env:ChocolateyInstall = [environment]::GetEnvironmentVariable('ChocolateyInstall', 'Machine')
544+
}
545+
535546
$chocoInstallCache = Join-Path -Path $env:ChocolateyInstall -ChildPath 'cache'
536547
if ( -not (Test-Path $chocoInstallCache)){
537548
New-Item -Name 'cache' -Path $env:ChocolateyInstall -ItemType Directory | Out-Null

0 commit comments

Comments
 (0)