|
1 | 1 | Set-StrictMode -Version 1.0 |
2 | 2 |
|
3 | | -$listofFiles = [System.IO.Directory]::EnumerateFiles(("{0}" -f $PSScriptRoot),"*.ps1","AllDirectories").Where({$_.EndsWith('.ps1')}) |
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)) |
11 | | - |
| 3 | +#Import monkey utils |
| 4 | +$modulesRoot = Split-Path -Parent $PSScriptRoot |
| 5 | +$monkeyutils = Join-Path $modulesRoot 'monkeyutils/monkeyutils.psd1' |
| 6 | +If (-not (Get-Module -Name 'monkeyutils')) { |
| 7 | + Import-Module $monkeyutils |
| 8 | +} |
| 9 | +# Import localized data |
12 | 10 | $LocalizedDataParams = @{ |
13 | 11 | BindingVariable = 'messages'; |
14 | | - BaseDirectory = "{0}/{1}" -f $PSScriptRoot, "Localized"; |
| 12 | + BaseDirectory = (Join-Path $PSScriptRoot 'Localized'); |
15 | 13 | } |
16 | 14 | #Import localized data |
17 | 15 | Import-LocalizedData @LocalizedDataParams; |
| 16 | + |
| 17 | +#Import public and private files |
| 18 | +$sourceFolders = @('private', 'public') |
| 19 | +ForEach ($folder in $sourceFolders) { |
| 20 | + $path = Join-Path $PSScriptRoot $folder |
| 21 | + If (-not (Test-Path $path)) { |
| 22 | + continue |
| 23 | + } |
| 24 | + $files = [System.IO.Directory]::EnumerateFiles($path,'*',[System.IO.SearchOption]::AllDirectories) |
| 25 | + ForEach ($file in ($files | Sort-Object)) { |
| 26 | + If ([System.IO.Path]::GetExtension($file) -ne '.ps1') { |
| 27 | + continue |
| 28 | + } |
| 29 | + . $file |
| 30 | + } |
| 31 | +} |
| 32 | + |
0 commit comments