-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport-ModuleInfoForLLM.psm1
More file actions
40 lines (36 loc) · 1.7 KB
/
Export-ModuleInfoForLLM.psm1
File metadata and controls
40 lines (36 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#Requires -Version 5.1
using namespace System.Collections.Generic
using namespace System.Text
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
# Check if we have the modular structure, otherwise load from parent
$publicFunctions = @(Get-ChildItem -Path "$PSScriptRoot\Public\*.ps1" -ErrorAction SilentlyContinue)
$privateFunctions = @(Get-ChildItem -Path "$PSScriptRoot\Private\*.ps1" -ErrorAction SilentlyContinue)
if ($publicFunctions.Count -gt 0 -or $privateFunctions.Count -gt 0) {
# Load from modular structure
foreach ($function in @($publicFunctions + $privateFunctions)) {
try {
Write-Verbose "Importing function: $($function.BaseName)"
. $function.FullName
}
catch {
Write-Error "Failed to import function $($function.FullName): $_"
}
}
# Export public functions
Export-ModuleMember -Function $publicFunctions.BaseName
} else {
# Load from single file in parent directory (temporary backward compatibility)
$parentModulePath = Join-Path (Split-Path $PSScriptRoot -Parent) 'Export-ModuleInfoForLLM.psm1'
if (Test-Path $parentModulePath) {
Write-Verbose "Loading module from parent directory for backward compatibility"
. $parentModulePath
# Note: The Export-ModuleMember at the end of the parent module file will handle exports
# We don't need to re-export here as it's already done in the sourced file
} else {
Write-Error "No module functions found. Expected either:"
Write-Error " - Functions in $PSScriptRoot\Public and $PSScriptRoot\Private"
Write-Error " - Module file at $parentModulePath"
throw "Module structure not found"
}
}