Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$ModuleScript = {
$folders = @('functions', 'private', 'classes')
ForEach ($folder in $folders)
{
$currentPath = $PSScriptRoot | Join-Path -ChildPath $folder
If (Test-Path -Path $currentPath -PathType Container)
{
$functions = Get-ChildItem -Path $currentPath -Filter '*.ps1'
ForEach ($function in $functions)
{
$encoding = [System.Text.Encoding]::UTF8
$script = [System.IO.File]::ReadAllText($function.FullName, $encoding)
. ([Scriptblock]::Create($script))
}
}
}
$splatItem = @{
Path = "$PSScriptRoot\functions"
Filter = '*.ps1'
}
$ExportFunctions = Get-ChildItem @splatItem | Select-Object -ExpandProperty BaseName
Export-ModuleMember -Function $ExportFunctions
}
Set-Content -Path .\FilesAPI.psm1 -Value $ModuleScript -Encoding UTF8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.