-
Notifications
You must be signed in to change notification settings - Fork 10
/
FormatPowershellCode.psm1
19 lines (16 loc) · 1 KB
/
FormatPowershellCode.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# This psm1 file is purely for development. The build script will recreate this file entirely.
# Private and other methods and variables
Get-ChildItem '.\src\private','.\src\other' -Recurse -Filter "*.ps1" -File | Sort-Object Name | Foreach {
Write-Verbose "Dot sourcing private script file: $($_.Name)"
. $_.FullName
}
# Load and export public methods
Get-ChildItem '.\src\public' -Recurse -Filter "*.ps1" -File | Sort-Object Name | Foreach {
Write-Verbose "Dot sourcing public script file: $($_.Name)"
. $_.FullName
# Find all the functions defined no deeper than the first level deep and export it.
# This looks ugly but allows us to not keep any uneeded variables in memory that are not related to the module.
([System.Management.Automation.Language.Parser]::ParseInput((Get-Content -Path $_.FullName -Raw), [ref]$null, [ref]$null)).FindAll({ $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $false) | Foreach {
Export-ModuleMember $_.Name
}
}