Last active
June 27, 2018 12:25
-
-
Save turboBasic/14ff13da77996cbfdba71223060a85f4 to your computer and use it in GitHub Desktop.
[Set-ModuleFunctions.ps1] dot-sources child functions to the module and populates list of public and private function names #powershell #module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Module initialization | |
foreach ($subDir in "private", "public") | |
{ | |
$currentFunctions = @() | |
Get-ChildItem -path (Join-Path -path $PSScriptRoot -childPath $subDir) ` | |
-filter *.ps1 -file -recurse | | |
ForEach-Object { | |
. $_.FullName | |
$currentFunctions += $_.BaseName | |
} | |
# create constants $privateFunctions and $publicFunctions | |
New-Variable -Name "${subDir}Functions" -Value $currentFunctions -Scope Script -Option ReadOnly | |
} | |
# $privateFunctions: list of all functions in .\private directory | |
# $publicFunctions: list of all functions in .\public directory | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment