Created
February 16, 2018 11:48
-
-
Save torgro/935fb92168eaec21e93834872f1f1fcd 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
$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