-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Labels
Description
ModuleBuilder is automatically exporting aliased in the module manifest if they are decorated with the attribute [Alias()]
.
The function that finds the alias to export is GetCommandAlias
.
I suggest we extend the function GetCommandAlias
to search for Set-Alias
as well.
Set-Alias -Name 'Task.Generate_Conceptual_Help' -Value "$PSScriptRoot/tasks/Generate_Conceptual_Help.build.ps1"
This will help when using the pattern with separate file for each alias in the Public folder, like Task.Generate_Conceptual_Help.ps1. We should make sure to only parse script files in the folder Public
to avoid the Set-Alias
is also used for private functions which should not be exported.
The function GetCommandAlias
here should be updated:
ModuleBuilder/Source/Private/GetCommandAlias.ps1
Lines 1 to 23 in abb0e09
function GetCommandAlias { | |
[CmdletBinding()] | |
param( | |
# Path to the PSM1 file to amend | |
[Parameter(Mandatory, ValueFromPipelineByPropertyName, ValueFromPipeline)] | |
[System.Management.Automation.Language.Ast]$AST | |
) | |
begin { | |
$Result = [Ordered]@{} | |
} | |
process { | |
foreach($function in $AST.FindAll( | |
{ $Args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, | |
$false ) | |
) { | |
$Result[$function.Name] = $function.Body.ParamBlock.Attributes.Where{ | |
$_.TypeName.Name -eq "Alias" }.PositionalArguments.Value | |
} | |
} | |
end { | |
$Result | |
} | |
} |