ps/Modules/Cole.PowerShell.Developer/Public/Get-CacheFile.ps1
2023-05-30 22:51:22 -07:00

25 lines
786 B
PowerShell

function Get-CacheFile {
param (
[Parameter(Mandatory = $true, Position = 0)]
[Alias('CacheKey')]
[Alias('FileName')]
$Name
)
$defaultCacheFolderName = "CachedFiles"
$alkamiPDPath = (Join-Path -Path $env:ProgramData -ChildPath "Alkami")
$defaultCacheFolder = (Join-Path $alkamiPDPath $defaultCacheFolderName)
$cacheFolder = (Get-EnvironmentVariable -Name "COLEMODULE_$($defaultCacheFolderName)_Path" 6>$null 5>$null 4>$null 3>$null)
if ([string]::IsNullOrWhiteSpace($overriddenCacheFolder)) {
$cacheFolder = $defaultCacheFolder
}
$targetPath = (Join-Path $cacheFolder $Name)
if (!(Test-Path $cacheFolder)) {
New-Item -Path $cacheFolder -ItemType Directory -Force
}
return $targetPath
}