57 lines
2.3 KiB
PowerShell
57 lines
2.3 KiB
PowerShell
Function Get-ContentFromFormatFilesInPath {
|
|
<#
|
|
.SYNOPSIS
|
|
Collects all content from valid files for inclusion into the PSM1
|
|
|
|
.DESCRIPTION
|
|
Collects all content from valid files for inclusion into the PSM1
|
|
* Skips test files
|
|
* Adds a header line saying where the file came from during compile
|
|
The reason for these files to match their names is about process, not a functional concern.
|
|
|
|
.EXAMPLE
|
|
Get-ContentFromFilesInPath .\Alkami.PowerShell.IIS\
|
|
|
|
.PARAMETER FolderPath
|
|
The name of the folder to examine all files under.
|
|
#>
|
|
[CmdletBinding()]
|
|
Param (
|
|
[String]$FolderPath
|
|
)
|
|
process {
|
|
$functionLines = @()
|
|
|
|
$prefixPath = (Split-Path $FolderPath -leaf)
|
|
|
|
$files = (Get-ChildItem (Join-Path $FolderPath "*.ps1xml"))
|
|
|
|
[Xml]$defaultXml = [Xml]@"
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
<Configuration>
|
|
</Configuration>
|
|
"@
|
|
$defaultXml.DocumentElement.AppendChild($defaultXml.CreateElement("SelectionSets")) | Out-Null
|
|
$defaultXml.DocumentElement.AppendChild($defaultXml.CreateElement("ViewDefinitions")) | Out-Null
|
|
$defaultXml.DocumentElement.AppendChild($defaultXml.CreateElement("Controls")) | Out-Null
|
|
$defaultXml.DocumentElement.AppendChild($defaultXml.CreateElement("DefaultSettings")) | Out-Null
|
|
|
|
foreach($file in $files) {
|
|
[Xml]$xml = [Xml](Get-Content $file.FullName)
|
|
foreach($node in $xml.DocumentElement.SelectionSets.ChildNodes) {
|
|
$defaultXml.DocumentElement.SelectSingleNode("SelectionSets").AppendChild($defaultXml.ImportNode($node,$true)) | Out-Null
|
|
}
|
|
foreach($node in $xml.DocumentElement.Controls.ChildNodes) {
|
|
$defaultXml.DocumentElement.SelectSingleNode("Controls").AppendChild($defaultXml.ImportNode($node,$true)) | Out-Null
|
|
}
|
|
foreach($node in $xml.DocumentElement.ViewDefinitions.ChildNodes) {
|
|
$defaultXml.DocumentElement.SelectSingleNode("ViewDefinitions").AppendChild($defaultXml.ImportNode($node,$true)) | Out-Null
|
|
}
|
|
foreach($node in $xml.DocumentElement.DefaultSettings.ChildNodes) {
|
|
$defaultXml.DocumentElement.SelectSingleNode("DefaultSettings").AppendChild($defaultXml.ImportNode($node,$true)) | Out-Null
|
|
}
|
|
}
|
|
|
|
return $defaultXml
|
|
}
|
|
} |