From 34c30eb30174c6d02db76957ca45e6cb7d289651 Mon Sep 17 00:00:00 2001 From: Edward Miller Date: Wed, 22 May 2024 13:38:30 -0500 Subject: [PATCH] allow configuring cache directory --- Public/ConvertTo-ExcelXlsx.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Public/ConvertTo-ExcelXlsx.ps1 b/Public/ConvertTo-ExcelXlsx.ps1 index 75b7362..b301089 100644 --- a/Public/ConvertTo-ExcelXlsx.ps1 +++ b/Public/ConvertTo-ExcelXlsx.ps1 @@ -7,7 +7,9 @@ function ConvertTo-ExcelXlsx { [parameter(Mandatory = $false)] [switch]$Force, [parameter(Mandatory = $false)] - [switch]$CacheToTemp + [switch]$CacheToTemp, + [parameter(Mandatory = $false)] + [string]$CacheDirectory ) process { try { @@ -53,7 +55,11 @@ function ConvertTo-ExcelXlsx { } if ($CacheToTemp) { - $tempPath = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetFileName($xlsFile.FullName)) + if (-not $CacheDirectory) { + $CacheDirectory = [System.IO.Path]::GetTempPath() + } + $tempPath = [System.IO.Path]::Combine($CacheDirectory, [System.IO.Path]::GetFileName($xlsFile.FullName)) + Write-Host ("Using Temp path: {0}" -f $tempPath) Copy-Item -Path $xlsFile.FullName -Destination $tempPath -Force $fileToProcess = $tempPath }