43 lines
1.3 KiB
PowerShell
43 lines
1.3 KiB
PowerShell
|
Function Update-FunctionNamesInPSD1 {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Concatenates all the function names from Get-FunctionNames for insertion into the PSD1 file referenced.
|
||
|
|
||
|
.EXAMPLE
|
||
|
Update-FunctionNamesInPSD1 .\Alkami.PowerShell.IIS\Public .\Alkami.PowerShell.IIS\Alkami.PowerShell.IIS.psd1
|
||
|
|
||
|
.PARAMETER FolderPath
|
||
|
The name of the folder to examine all files under.
|
||
|
|
||
|
.PARAMETER Psd1FilePath
|
||
|
The file to be rewritten. (This is called out in case more than one .psd1 file exists in a folder.)
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
Param (
|
||
|
[String]$FolderPath,
|
||
|
[String]$Psd1FilePath
|
||
|
)
|
||
|
process {
|
||
|
$functionNames = @(Get-FunctionNames $FolderPath) | Sort-Object
|
||
|
|
||
|
$toBeJoinedFunctionNames = @()
|
||
|
|
||
|
foreach($name in $functionNames) {
|
||
|
$toBeJoinedFunctionNames += "'$name'"
|
||
|
}
|
||
|
|
||
|
$joinedFunctionNames = $toBeJoinedFunctionNames -Join ','
|
||
|
|
||
|
$contents = (Get-Content $Psd1FilePath)
|
||
|
$newContents = @()
|
||
|
|
||
|
foreach($line in $contents) {
|
||
|
if ($line.Trim().StartsWith("FunctionsToExport")) {
|
||
|
$splits = $line -split '='
|
||
|
$line = $splits[0].TrimEnd() + " = $joinedFunctionNames"
|
||
|
}
|
||
|
$newContents += $line
|
||
|
}
|
||
|
Set-Content -Path $Psd1FilePath -Value $newContents
|
||
|
}
|
||
|
}
|