Created
April 4, 2022 10:01
-
-
Save pandieme/7d4ce322df3821ae75a1fb5f3db49db9 to your computer and use it in GitHub Desktop.
This file contains 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
function Import-ModuleFunctions( | |
[Parameter()] | |
[array] | |
$Roots = @( | |
"$PSScriptRoot/public" | |
"$PSScriptRoot/private" | |
), | |
[Parameter()] | |
[switch] | |
$All | |
) { | |
<# | |
.SYNOPSIS | |
Import module functions | |
#> | |
$PublicFunctions = $() | |
$Roots | ForEach-Object { | |
if (Test-Path -Path $_) { | |
Get-ChildItem -Path $_ -Filter "*.ps1" -Recurse | ` | |
ForEach-Object { | |
if ($_ -match 'public') { | |
$PublicFunctions += $_.BaseName | |
} | |
elseif ($All) { | |
$PublicFunctions += $_.BaseName | |
} | |
$AllFunctions += $_.BaseName | |
. $_.FullName | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment