From 7e29b24a11ae11f4ba56278f95df184b0c12ad10 Mon Sep 17 00:00:00 2001 From: Joel Timothy Oh Date: Tue, 14 May 2024 05:07:46 +0000 Subject: [PATCH] Enhancement (module): Simplify script module file --- .../PSRepositoryReleaseManager.psm1 | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.psm1 b/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.psm1 index 108382b..33327a4 100644 --- a/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.psm1 +++ b/src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.psm1 @@ -1,21 +1,16 @@ Set-StrictMode -Version Latest -################## -# Module globals # -################## +# Initialize variables +$MODULE_BASE_DIR = $PSScriptRoot +$MODULE_PRIVATE_DIR = Join-Path $MODULE_BASE_DIR 'Private' +$MODULE_PUBLIC_DIR = Join-Path $MODULE_BASE_DIR 'Public' +$MODULE_GENERATE_DIR = Join-Path $MODULE_BASE_DIR 'generate' +$MODULE_VARIANT_DIR = Join-Path $MODULE_GENERATE_DIR 'variants' -# Module constants -$script:MODULE = @{} -$script:MODULE['BASE_DIR'] = $PSScriptRoot -$script:MODULE['PUBLIC_DIR'] = Join-Path $script:MODULE['BASE_DIR'] 'Public' # Module public functions -$script:MODULE['PRIVATE_DIR'] = Join-Path $script:MODULE['BASE_DIR'] 'Private' # Module private functions -$script:MODULE['GENERATE_DIR'] = Join-Path $script:MODULE['BASE_DIR'] 'generate' -$script:MODULE['VARIANT_DIR'] = Join-Path $script:MODULE['GENERATE_DIR'] 'variants' +# Load functions +Get-ChildItem "$MODULE_PRIVATE_DIR\*.ps1" -exclude *.Tests.ps1 | % { . $_.FullName } +Get-ChildItem "$MODULE_PUBLIC_DIR\*.ps1" -exclude *.Tests.ps1 | % { . $_.FullName } +Get-ChildItem "$MODULE_VARIANT_DIR\*.ps1" -exclude *.Tests.ps1 | % { . $_.FullName } -# Load vendor, Public, Private, classes, helpers -Get-ChildItem -Path "$($script:MODULE['PUBLIC_DIR'])\*.ps1" | % { . $_.FullName } -Get-ChildItem -Path "$($script:MODULE['PRIVATE_DIR'])\*.ps1" | % { . $_.FullName } -Get-ChildItem -Path "$($script:MODULE['VARIANT_DIR'])\*.ps1" | % { . $_.FullName } - -# Export Public functions -Export-ModuleMember -Function (Get-ChildItem "$($script:MODULE['PUBLIC_DIR'])\*.ps1" | Select-Object -ExpandProperty BaseName) +# Export functions +Export-ModuleMember -Function (Get-ChildItem "$MODULE_PUBLIC_DIR\*.ps1" | Select-Object -ExpandProperty BaseName)