Gordon.psm1

$PsVersion = $PSVersionTable.PSVersion
if ($PsVersion.Major -le 5) {
    $BinaryModulePath = "$PSScriptRoot\net48"
}
else {
    $BinaryModulePath = "$PSScriptRoot\net6.0"
}
Write-Host "Running on PS $PsVersion, loading module from $BinaryModulePath"
$filesToEmit = @(
    "Eos.Gordon.PowerShell.dll"
    "Eos.Gordon.Core.dll"
    "Eos.Nav.Al.dll"
)
foreach ($file in $filesToEmit) {
    $path = [System.IO.FileInfo]::new((Join-Path $BinaryModulePath $file))
    if (-not $path.Exists) { continue }
    $fvi = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($path.FullName)
    Write-Host "$($path.Name): $($fvi.ProductVersion)"
}

# Import the actual binary module
Import-Module "$BinaryModulePath\Eos.Gordon.PowerShell.dll" -DisableNameChecking -Global

# Load alias functions from the 'Aliases' folder
Get-ChildItem $PSScriptRoot\Aliases | ForEach-Object {
    . $_.FullName
}

# Because using 'Export-ModuleMember' above causes binary cmdlets to no longer be exported automatically, we need to so explicitly.
$BinaryCmdlets = [Eos.Gordon.PowerShell.Globals]::EnumerateCmdletNames()
Export-ModuleMember -Cmdlet $BinaryCmdlets