33
44BeforeAll {
55 # Import the module (cross-platform path)
6- $ModulePath = Join-Path $PSScriptRoot " .." " ColorScripts-Enhanced"
6+ $ModulePath = Join-Path - Path $PSScriptRoot - ChildPath " .."
7+ $ModulePath = Join-Path - Path $ModulePath - ChildPath " ColorScripts-Enhanced"
78 Import-Module $ModulePath - Force
89}
910
@@ -48,7 +49,9 @@ Describe "ColorScripts-Enhanced Module" {
4849
4950 Context " Module Manifest" {
5051 BeforeAll {
51- $script :ManifestPath = Join-Path $PSScriptRoot " .." " ColorScripts-Enhanced" " ColorScripts-Enhanced.psd1"
52+ $script :ManifestPath = Join-Path - Path $PSScriptRoot - ChildPath " .."
53+ $script :ManifestPath = Join-Path - Path $script :ManifestPath - ChildPath " ColorScripts-Enhanced"
54+ $script :ManifestPath = Join-Path - Path $script :ManifestPath - ChildPath " ColorScripts-Enhanced.psd1"
5255 $script :Manifest = Test-ModuleManifest $script :ManifestPath - ErrorAction Stop
5356 }
5457
@@ -70,12 +73,16 @@ Describe "ColorScripts-Enhanced Module" {
7073
7174 Context " Scripts Directory" {
7275 It " Should have Scripts directory" {
73- $scriptsPath = Join-Path $PSScriptRoot " .." " ColorScripts-Enhanced" " Scripts"
76+ $scriptsPath = Join-Path - Path $PSScriptRoot - ChildPath " .."
77+ $scriptsPath = Join-Path - Path $scriptsPath - ChildPath " ColorScripts-Enhanced"
78+ $scriptsPath = Join-Path - Path $scriptsPath - ChildPath " Scripts"
7479 Test-Path $scriptsPath | Should - Be $true
7580 }
7681
7782 It " Should contain colorscript files" {
78- $scriptsPath = Join-Path $PSScriptRoot " .." " ColorScripts-Enhanced" " Scripts"
83+ $scriptsPath = Join-Path - Path $PSScriptRoot - ChildPath " .."
84+ $scriptsPath = Join-Path - Path $scriptsPath - ChildPath " ColorScripts-Enhanced"
85+ $scriptsPath = Join-Path - Path $scriptsPath - ChildPath " Scripts"
7986 $scripts = Get-ChildItem $scriptsPath - Filter " *.ps1" |
8087 Where-Object { $_.Name -ne ' ColorScriptCache.ps1' }
8188 $scripts.Count | Should - BeGreaterThan 0
@@ -84,7 +91,21 @@ Describe "ColorScripts-Enhanced Module" {
8491
8592 Context " Cache System" {
8693 BeforeAll {
87- $script :CacheDir = Join-Path $env: APPDATA " ColorScripts-Enhanced\cache"
94+ # Use cross-platform cache directory
95+ if ($IsWindows -or $PSVersionTable.PSVersion.Major -le 5 ) {
96+ $script :CacheDir = Join-Path - Path $env: APPDATA - ChildPath " ColorScripts-Enhanced"
97+ $script :CacheDir = Join-Path - Path $script :CacheDir - ChildPath " cache"
98+ }
99+ elseif ($IsMacOS ) {
100+ $script :CacheDir = Join-Path - Path $HOME - ChildPath " Library"
101+ $script :CacheDir = Join-Path - Path $script :CacheDir - ChildPath " Application Support"
102+ $script :CacheDir = Join-Path - Path $script :CacheDir - ChildPath " ColorScripts-Enhanced"
103+ $script :CacheDir = Join-Path - Path $script :CacheDir - ChildPath " cache"
104+ }
105+ else {
106+ $xdgCache = if ($env: XDG_CACHE_HOME ) { $env: XDG_CACHE_HOME } else { Join-Path - Path $HOME - ChildPath " .cache" }
107+ $script :CacheDir = Join-Path - Path $xdgCache - ChildPath " ColorScripts-Enhanced"
108+ }
88109 }
89110
90111 It " Should create cache directory" {
@@ -93,14 +114,14 @@ Describe "ColorScripts-Enhanced Module" {
93114
94115 It " Should build cache for a script" {
95116 Build-ColorScriptCache - Name " bars" - ErrorAction Stop
96- $cacheFile = Join-Path $script :CacheDir " bars.cache"
117+ $cacheFile = Join-Path - Path $script :CacheDir - ChildPath " bars.cache"
97118 Test-Path $cacheFile | Should - Be $true
98119 }
99120
100121 It " Should clear specific cache" {
101122 Build-ColorScriptCache - Name " bars" - ErrorAction Stop
102123 Clear-ColorScriptCache - Name " bars" - Confirm:$false
103- $cacheFile = Join-Path $script :CacheDir " bars.cache"
124+ $cacheFile = Join-Path - Path $script :CacheDir - ChildPath " bars.cache"
104125 Test-Path $cacheFile | Should - Be $false
105126 }
106127 }
@@ -279,7 +300,24 @@ Describe "Script Quality" {
279300
280301AfterAll {
281302 # Cleanup test cache if needed
282- $testCache = Join-Path $env: APPDATA " ColorScripts-Enhanced\cache\bars.cache"
303+ if ($IsWindows -or $PSVersionTable.PSVersion.Major -le 5 ) {
304+ $cacheBase = Join-Path - Path $env: APPDATA - ChildPath " ColorScripts-Enhanced"
305+ $testCache = Join-Path - Path $cacheBase - ChildPath " cache"
306+ $testCache = Join-Path - Path $testCache - ChildPath " bars.cache"
307+ }
308+ elseif ($IsMacOS ) {
309+ $cacheBase = Join-Path - Path $HOME - ChildPath " Library"
310+ $cacheBase = Join-Path - Path $cacheBase - ChildPath " Application Support"
311+ $cacheBase = Join-Path - Path $cacheBase - ChildPath " ColorScripts-Enhanced"
312+ $testCache = Join-Path - Path $cacheBase - ChildPath " cache"
313+ $testCache = Join-Path - Path $testCache - ChildPath " bars.cache"
314+ }
315+ else {
316+ $xdgCache = if ($env: XDG_CACHE_HOME ) { $env: XDG_CACHE_HOME } else { Join-Path - Path $HOME - ChildPath " .cache" }
317+ $cacheBase = Join-Path - Path $xdgCache - ChildPath " ColorScripts-Enhanced"
318+ $testCache = Join-Path - Path $cacheBase - ChildPath " bars.cache"
319+ }
320+
283321 if (Test-Path $testCache ) {
284322 Remove-Item $testCache - Force - ErrorAction SilentlyContinue
285323 }
0 commit comments