Skip to content

Commit eb3ae51

Browse files
StartAutomatingStartAutomating
authored andcommitted
Updating PipeScript.ps1.psm1 (alignment of ModuleExports) (#104)
1 parent 791d051 commit eb3ae51

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

PipeScript.psm1

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

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

4142
Export-ModuleMember -Function * -Alias $aliasNames

0 commit comments

Comments
 (0)