Skip to content

Commit bb36caa

Browse files
committed
update monkey cloud utils
1 parent 50ac737 commit bb36caa

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,38 @@
11
Set-StrictMode -Version Latest
22

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-
#Set-Content -Path $tmpFile -Value $content
9-
. ([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
106

7+
#Import monkeymsal
8+
$modulesRoot = Split-Path -Parent $PSScriptRoot
9+
$monkeymsal = Join-Path $modulesRoot 'monkeymsal/monkeymsal.psd1'
10+
If (-not (Get-Module -Name 'monkeymsal')) {
11+
Import-Module $monkeymsal
12+
}
13+
14+
# Import localized data
1115
$LocalizedDataParams = @{
1216
BindingVariable = 'messages';
13-
BaseDirectory = "{0}/{1}" -f $PSScriptRoot, "Localized";
17+
BaseDirectory = (Join-Path $PSScriptRoot 'Localized');
1418
}
1519
#Import localized data
1620
Import-LocalizedData @LocalizedDataParams;
21+
22+
#Import public and private files
23+
$sourceFolders = @('private', 'public')
24+
ForEach ($folder in $sourceFolders) {
25+
$path = Join-Path $PSScriptRoot $folder
26+
If (-not (Test-Path $path)) {
27+
continue
28+
}
29+
$files = [System.IO.Directory]::EnumerateFiles($path,'*',[System.IO.SearchOption]::AllDirectories)
30+
ForEach ($file in ($files | Sort-Object)) {
31+
If ([System.IO.Path]::GetExtension($file) -ne '.ps1') {
32+
continue
33+
}
34+
. $file
35+
}
36+
}
37+
#Export module members
38+
Export-ModuleMember -Function $publicFunctions

0 commit comments

Comments
 (0)