Skip to content

Commit 182c73f

Browse files
StartAutomatingStartAutomating
authored andcommitted
Merge branch 'PipeScriptFunAndFixes' of https://github.com/StartAutomating/PipeScript into PipeScriptFunAndFixes
1 parent 765779e commit 182c73f

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

PipeScript.psm1

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,29 @@ foreach ($transpilerCmd in Get-Transpiler) {
1313
}
1414

1515
$MyModule = $MyInvocation.MyCommand.ScriptBlock.Module
16-
foreach ($cmd in $ExecutionContext.SessionState.InvokeCommand.GetCommands('*','Function', $true)) {
17-
if ($cmd.ScriptBlock.Module -ne $MyModule) { continue }
18-
if ($cmd.ScriptBlock.Attributes.AliasNames) {
19-
$aliasNames += $cmd.ScriptBlock.Attributes.AliasNames
20-
}
21-
}
16+
$aliasNames +=
17+
@(
18+
if ($MyModule -isnot [Management.Automation.PSModuleInfo]) {
19+
Write-Error "'$MyModule' must be a [Management.Automation.PSModuleInfo]"
20+
} elseif ($MyModule.ExportedCommands.Count) {
21+
foreach ($cmd in $MyModule.ExportedCommands.Values) {
22+
if ($cmd.CommandType -in 'Alias') {
23+
$cmd
24+
}
25+
}
26+
} else {
27+
foreach ($cmd in $ExecutionContext.SessionState.InvokeCommand.GetCommands('*', 'Function,Cmdlet', $true)) {
28+
if ($cmd.Module -ne $MyModule) { continue }
29+
if ('Alias' -contains 'Alias' -and $cmd.ScriptBlock.Attributes.AliasNames) {
30+
foreach ($aliasName in $cmd.ScriptBlock.Attributes.AliasNames) {
31+
$ExecutionContext.SessionState.InvokeCommand.GetCommand($aliasName, 'Alias')
32+
}
33+
}
34+
if ('Alias' -contains $cmd.CommandType) {
35+
$cmd
36+
}
37+
}
38+
})
39+
2240

2341
Export-ModuleMember -Function * -Alias $aliasNames

0 commit comments

Comments
 (0)