ps/Modules/.build/Load-Includes.ps1
2023-05-30 22:51:22 -07:00

24 lines
1.2 KiB
PowerShell

## This file tries to load functions if they haven't been loaded into scope yet.
## We know if things are in the scope if the magic function Get-ContentFromFilesInPath has been loaded into the current session scope
## The way that this is loaded is from this file or manually
## This file was chosen because it doesn't live in any module for building the powershell modules
## The use of this file is as such:
## . $PSScriptRoot\.build\Load-Includes.ps1
## The use-case of this file and the unusual style is that this is just to include things for execution in the build system
## This is not a typical style of how to load things. This is a micro-op.
$script:buildFilesLoaded = $script:buildFilesLoaded -or ($null -ne ${function:Get-ContentFromFilesInPath})
if (!($script:buildFilesLoaded)) {
$buildScriptsFolder = $PSScriptRoot
if (Test-Path $buildScriptsFolder) {
$buildScripts = (Get-ChildItem *.ps1 -Path $buildScriptsFolder -Exclude "Load-Includes.ps1" -Recurse)
foreach($script in $buildScripts) {
Write-Verbose "[Clean-Project] - Including the build files: $script"
. $script.FullName
}
$script:buildFilesLoaded = $true
}
}