Skip to content

Instantly share code, notes, and snippets.

@turboBasic
Last active June 27, 2018 12:25
Show Gist options
  • Save turboBasic/14ff13da77996cbfdba71223060a85f4 to your computer and use it in GitHub Desktop.
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
#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