-
Notifications
You must be signed in to change notification settings - Fork 1
/
BoxOptimizer.psm1
34 lines (33 loc) · 1.11 KB
/
BoxOptimizer.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env pwsh
#region Classes
#endregion Classes
$Private = Get-ChildItem ([IO.Path]::Combine($PSScriptRoot, 'Private')) -Filter "*.ps1" -ErrorAction SilentlyContinue
$Public = Get-ChildItem ([IO.Path]::Combine($PSScriptRoot, 'Public')) -Filter "*.ps1" -ErrorAction SilentlyContinue
# Load dependencies
$PrivateModules = [string[]](Get-ChildItem ([IO.Path]::Combine($PSScriptRoot, 'Private')) -ErrorAction SilentlyContinue | Where-Object { $_.PSIsContainer } | Select-Object -ExpandProperty FullName)
if ($PrivateModules.Count -gt 0) {
ForEach ($Module in $PrivateModules) {
Try {
Import-Module $Module -ErrorAction Stop
} Catch {
Write-Error "Failed to import module $Module : $_"
}
}
}
# Dot source the files
ForEach ($Import in ($Public, $Private)) {
Try {
. $Import.fullname
} Catch {
Write-Warning "Failed to import function $($Import.BaseName): $_"
$host.UI.WriteErrorLine($_)
}
}
# Export Public Functions
$Param = @{
Function = $Public.BaseName
Variable = '*'
Cmdlet = '*'
Alias = '*'
}
Export-ModuleMember @Param -Verbose