Skip to content

Instantly share code, notes, and snippets.

@torgro
Created February 16, 2018 11:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save torgro/935fb92168eaec21e93834872f1f1fcd to your computer and use it in GitHub Desktop.
Save torgro/935fb92168eaec21e93834872f1f1fcd to your computer and use it in GitHub Desktop.
$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