|
1 | 1 | Set-StrictMode -Version 1.0 |
2 | 2 |
|
3 | | -$listofFiles = [System.IO.Directory]::EnumerateFiles(("{0}" -f $PSScriptRoot),"*.ps1","AllDirectories") |
4 | | -$all_files = $listofFiles.Where({($_ -like "*public*") -or ($_ -like "*private*")}) |
5 | | -$content = $all_files.ForEach({ |
6 | | - [System.IO.File]::ReadAllText($_, [Text.Encoding]::UTF8) + [Environment]::NewLine |
7 | | -}) |
8 | | - |
9 | | -#Set-Content -Path $tmpFile -Value $content |
10 | | -. ([scriptblock]::Create($content)) |
| 3 | +#Get public functions |
| 4 | +$PublicFolder = Join-Path -Path $PSScriptRoot -ChildPath "public" |
| 5 | +$publicFunctions = (Get-ChildItem -Path $PublicFolder -Filter *.ps1 -File).BaseName |
11 | 6 |
|
| 7 | +# Import localized data |
12 | 8 | $LocalizedDataParams = @{ |
13 | 9 | BindingVariable = 'messages'; |
14 | | - BaseDirectory = "{0}/{1}" -f $PSScriptRoot, "Localized"; |
| 10 | + BaseDirectory = (Join-Path $PSScriptRoot 'Localized'); |
15 | 11 | } |
16 | 12 | #Import localized data |
17 | 13 | Import-LocalizedData @LocalizedDataParams; |
| 14 | + |
| 15 | +#Import public and private files |
| 16 | +$sourceFolders = @('private', 'public') |
| 17 | +ForEach ($folder in $sourceFolders) { |
| 18 | + $path = Join-Path $PSScriptRoot $folder |
| 19 | + If (-not (Test-Path $path)) { |
| 20 | + continue |
| 21 | + } |
| 22 | + $files = [System.IO.Directory]::EnumerateFiles($path,'*',[System.IO.SearchOption]::AllDirectories) |
| 23 | + ForEach ($file in ($files | Sort-Object)) { |
| 24 | + If ([System.IO.Path]::GetExtension($file) -ne '.ps1') { |
| 25 | + continue |
| 26 | + } |
| 27 | + . $file |
| 28 | + } |
| 29 | +} |
| 30 | +#Export module members |
| 31 | +Export-ModuleMember -Function $publicFunctions |
0 commit comments