template/module/Module.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
###############################################################
# Avoid putting any additional logic in this PSM1 because if
# it the module is compiled into a monolithic PSM1, this file
# is created from scratch.
#
# Instead, initialization logic should go into Initialize.ps1.
# That file will be compiled into the PSM1 if that option is
# enabled in $PSBPreference.Build.CompileModule
###############################################################
. (Join-Path -Path $PSScriptRoot -ChildPath 'Initialize.ps1')

# Dot source public/private functions
$public  = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Public/*.ps1')  -Recurse -ErrorAction Stop)
$private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'Private/*.ps1') -Recurse -ErrorAction Stop)
foreach ($import in @($public + $private)) {
    try {
        . $import.FullName
    } catch {
        throw "Unable to dot source [$($import.FullName)]"
    }
}

Export-ModuleMember -Function $public.Basename