diff --git a/src/NewPlasterManifest.ps1 b/src/NewPlasterManifest.ps1 index 9494adf..878f2eb 100644 --- a/src/NewPlasterManifest.ps1 +++ b/src/NewPlasterManifest.ps1 @@ -47,7 +47,15 @@ function New-PlasterManifest { [Parameter()] [switch] - $AddContent + $AddContent, + + [Parameter()] + [string[]] + $Parameters, + + [Parameter()] + [string[]] + $Content ) begin { @@ -104,13 +112,23 @@ function New-PlasterManifest { $srcAttr = $manifest.CreateAttribute("source") $srcAttr.Value = $filename - $fileElem.Attributes.Append($srcAttr) > $null + $null = $fileElem.Attributes.Append($srcAttr) $dstAttr = $manifest.CreateAttribute("destination") $dstAttr.Value = $filename - $fileElem.Attributes.Append($dstAttr) > $null + $null = $fileElem.Attributes.Append($dstAttr) - $manifest.plasterManifest["content"].AppendChild($fileElem) > $null + $null = $manifest.plasterManifest["content"].AppendChild($fileElem) + } + } + else { + # If we passed some parameter xml then assign it + if (-not [string]::IsNullOrEmpty($Parameters)) { + $null = $manifest.plasterManifest["parameters"].InnerXML = ($Parameters -join '') + } + # If we passed some content xml then assign it + if (-not [string]::IsNullOrEmpty($Content)) { + $null = $manifest.plasterManifest["content"].InnerXML = ($Content -join '') } } diff --git a/test/NewPlasterManifest.Tests.ps1 b/test/NewPlasterManifest.Tests.ps1 index 053eb69..f6f60e7 100644 --- a/test/NewPlasterManifest.Tests.ps1 +++ b/test/NewPlasterManifest.Tests.ps1 @@ -142,6 +142,82 @@ Describe 'New-PlasterManifest Command Tests' { Test-PlasterManifest -Path $plasterPath | Should Not BeNullOrEmpty CompareManifestContent $expectedManifest $plasterPath } + + It 'Parameters and Content parameters work' { + CleanDir $OutDir + + $expectedManifest = @" + + + + TemplateName + 1a1b0933-78b2-4a3e-bf48-492591e69521 + 1.0.0 + TemplateName + + + + + + + + + + + + + + + + + + +"@ + + $ParametersParam = @( + '', + '', + '' + ) + + $ContentParam = @( + '', + '', + '', + '', + '', + '' + ) + + $plasterPath = "$OutDir\plasterManifest.xml" + Copy-Item $PSScriptRoot\Recurse $OutDir -Recurse + New-PlasterManifest -Path $plasterPath -Id '1a1b0933-78b2-4a3e-bf48-492591e69521' -TemplateName 'TemplateName' -TemplateType 'project' -Content $ContentParam -Parameters $ParametersParam + Test-PlasterManifest -Path $plasterPath | Should Not BeNullOrEmpty + CompareManifestContent $expectedManifest $plasterPath + } } Context 'Parameter tests' {