Ghost.psm1

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

# The active connection. Connect-Ghost fills it and Disconnect-Ghost clears it.
$script:GhostConnection = $null

# Every .ps1 file in Private and Public holds one function with the same name as the file. The extension is
# compared afterwards because the filter *.ps1 also matches .ps1xml on Windows PowerShell.
$functions = @{}
foreach ($folder in @('Private', 'Public')) {
    $path = Join-Path -Path $PSScriptRoot -ChildPath $folder
    $files = Get-ChildItem -Path $path -File | Where-Object { $_.Extension -eq '.ps1' }
    $functions[$folder] = @($files | Sort-Object -Property Name)
    foreach ($file in $functions[$folder]) {
        . $file.FullName
    }
}

# Only the functions in Public are exported. The manifest lists the same names, see build/build.ps1.
Export-ModuleMember -Function $functions['Public'].BaseName