Skip to content

Commit b28a6ba

Browse files
committed
fix(core): import CommonEnums in SafeImport before Validation to ensure FileSystemPathType is available
1 parent 6b78b35 commit b28a6ba

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

scripts/lib/core/SafeImport.psm1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,24 @@ scripts/lib/core/SafeImport.psm1
1414
PowerShell Version: 3.0+
1515
#>
1616

17+
# Import CommonEnums first - Validation requires FileSystemPathType enum
18+
# Must be imported before Validation since Validation uses FileSystemPathType in function signatures
19+
$commonEnumsPath = Join-Path $PSScriptRoot 'CommonEnums.psm1'
20+
if ($commonEnumsPath -and -not [string]::IsNullOrWhiteSpace($commonEnumsPath) -and (Test-Path -LiteralPath $commonEnumsPath)) {
21+
try {
22+
Import-Module $commonEnumsPath -DisableNameChecking -Force -Global -ErrorAction Stop
23+
}
24+
catch {
25+
# CommonEnums import failed - Validation may fail to parse
26+
$debugLevel = 0
27+
if ($env:PS_PROFILE_DEBUG -and [int]::TryParse($env:PS_PROFILE_DEBUG, [ref]$debugLevel) -and $debugLevel -ge 1) {
28+
Write-Warning "[safe-import.init] Failed to import CommonEnums: $($_.Exception.Message). Validation module may fail to load."
29+
}
30+
}
31+
}
32+
1733
# Import Validation module for path validation
34+
# Note: Validation uses FileSystemPathType which must be available from CommonEnums
1835
$validationModulePath = Join-Path $PSScriptRoot 'Validation.psm1'
1936
if ($validationModulePath -and -not [string]::IsNullOrWhiteSpace($validationModulePath) -and (Test-Path -LiteralPath $validationModulePath)) {
2037
Import-Module $validationModulePath -DisableNameChecking -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)