Skip to content

Instantly share code, notes, and snippets.

@Cologler
Created November 13, 2021 06:15
Show Gist options
  • Save Cologler/ee4a5d887951344cd9f88b48de552273 to your computer and use it in GitHub Desktop.
Save Cologler/ee4a5d887951344cd9f88b48de552273 to your computer and use it in GitHub Desktop.
load all partial scripts to caller context.
# load all partial scripts to caller context.
# - for caller, add `. "$(Split-Path $PSCommandPath)\Load-PartialScripts.ps1"`;
# - the partial scripts must named `{caller}.{partial}.ps1`;
foreach (
$item in $(
Get-ChildItem `
-Path $(Split-Path $MyInvocation.PSCommandPath -Parent -Resolve) `
-Filter "$(Split-Path $MyInvocation.PSCommandPath -LeafBase).*$(Split-Path $MyInvocation.PSCommandPath -Extension)" `
| Sort-Object { Split-Path $_ -LeafBase }
)
) {
. $item.FullName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment