Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scripts/helpers/Build-PSModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,11 @@ function Build-PSModule {
Build-PSModuleBase -ModuleName $ModuleName -ModuleSourceFolder $moduleSourceFolder -ModuleOutputFolder $moduleOutputFolder
Build-PSModuleManifest -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder
Build-PSModuleRootModule -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder
Update-PSModuleManifestAliasesToExport -ModuleName $ModuleName -ModuleOutputFolder $moduleOutputFolder
Build-PSModuleDocumentation -ModuleName $ModuleName -DocsOutputFolder $docsOutputFolder

$outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1"
Start-LogGroup 'Build manifest file - Final Result'
Show-FileContent -Path $outputManifestPath
Stop-LogGroup
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function Update-PSModuleManifestAliasesToExport {
<#
.SYNOPSIS
Updates the aliases to export in the module manifest.
#>
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function',
Justification = 'Updates a file that is being built.'
)]
[CmdletBinding()]
param(
# Name of the module.
[Parameter(Mandatory)]
[string] $ModuleName,

# Folder where the module is outputted.
[Parameter(Mandatory)]
[System.IO.DirectoryInfo] $ModuleOutputFolder
)

$aliases = Get-Command -Module $ModuleName -CommandType Alias
$outputManifestPath = Join-Path -Path $ModuleOutputFolder -ChildPath "$ModuleName.psd1"
Set-ModuleManifest -Path $outputManifestPath -AliasesToExport $aliases.Name -Verbose:$false
}
8 changes: 8 additions & 0 deletions tests/src/public/New-PSModuleTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function New-PSModuleTest {
'PSUseShouldProcessForStateChangingFunctions', '', Scope = 'Function',
Justification = 'Reason for suppressing'
)]
[Alias('New-PSModuleTestAlias1')]
[Alias('New-PSModuleTestAlias2')]
[CmdletBinding()]
param (
# Name of the person to greet.
Expand All @@ -27,3 +29,9 @@ function New-PSModuleTest {
)
Write-Output "Hello, $Name!"
}

New-Alias New-PSModuleTestAlias3 New-PSModuleTest
New-Alias -Name New-PSModuleTestAlias4 -Value New-PSModuleTest


Set-Alias New-PSModuleTestAlias5 New-PSModuleTest