Skip to content

Commit

Permalink
Enhancement (module): Simplify script module file
Browse files Browse the repository at this point in the history
  • Loading branch information
joeltimothyoh committed May 14, 2024
1 parent 6474c0a commit 7e29b24
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/PSRepositoryReleaseManager/PSRepositoryReleaseManager.psm1
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 7e29b24

Please sign in to comment.