Skip to content

Commit

Permalink
resolves Auto add aliases on build #9
Browse files Browse the repository at this point in the history
  • Loading branch information
darksidemilk committed Aug 22, 2024
1 parent f903fe9 commit a3ea3bc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,18 @@ function Get-AliasesToExport {
[CmdletBinding()]
param (
[string]$psm1Path,
[bool]$loop=$false
[bool]$loop=$false,
[string]$modulePath
)

process {
if ($loop -eq $false) {
$modulePath = (Get-Item $psm1Path).PSParentPath;
if ([string]::IsNullOrEmpty($modulePath)) {
$modulePath = "$((Get-Item $psm1Path).PSParentPath)";
if (!(Test-Path $modulePath)) {
$modulePath = "$((Get-Item $psm1Path).PSParentPath)\$((Get-item $psm1Path).BaseName)";
}
}
$PublicFunctions = Get-ChildItem "$modulePath\Public" -Recurse -Filter '*.ps1' -EA 0;;
if ($null -ne $PublicFunctions) {
$aliasList = New-Object System.Collections.Generic.List[string];
Expand Down Expand Up @@ -199,7 +205,7 @@ function Get-AliasesToExport {
}
$aliases += $null;
}
return $aliases;
return $aliases | Sort-Object -Unique;
}
}
function Install-Requirements {
Expand Down Expand Up @@ -346,7 +352,7 @@ $moduleFile = "$buildPth\$moduleName.psm1";
$PublicFunctions = Get-ChildItem "$modulePath\Public" -Recurse -Filter '*.ps1' -EA 0;
$Classes = Get-ChildItem "$modulePath\Classes" -Recurse -Filter '*.ps1' -EA 0;
$PrivateFunctions = Get-ChildItem "$modulePath\Private" -Recurse -Filter '*.ps1' -EA 0;
$aliases = Get-AliasesToExport -psm1Path $moduleFile;
$aliases = Get-AliasesToExport -psm1Path $moduleFile -modulePath $modulePath;
# mkdir "$PSSCriptRoot\ModuleBuild" -EA 0;
# $buildPth = "$env:userprofile\ModuleBuild\$moduleName";

Expand Down

0 comments on commit a3ea3bc

Please sign in to comment.