diff --git a/PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1 b/PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1 index fbb82cc..0b9223f 100644 --- a/PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1 +++ b/PSModuleDevelopment/functions/templating/Invoke-PSMDTemplate.ps1 @@ -337,7 +337,7 @@ Write-PSFMessage -Level Verbose -Message "Creating Template-Item: $($Item.Name) ($($Item.RelativePath))" -FunctionName Invoke-PSMDTemplate -ModuleName PSModuleDevelopment -Tag 'create', 'template' $identifier = $Item.Identifier - $isFile = $Item.GetType().Name -eq 'TemplateItemFile' + $isFile = $Item.PSObject.Properties.Name -contains 'Value' #region File if ($isFile) { diff --git a/PSModuleDevelopment/tests/functions/Templates.Tests.ps1 b/PSModuleDevelopment/tests/functions/Templates.Tests.ps1 index 3e38b57..4f71d83 100644 --- a/PSModuleDevelopment/tests/functions/Templates.Tests.ps1 +++ b/PSModuleDevelopment/tests/functions/Templates.Tests.ps1 @@ -1,9 +1,13 @@ Describe "Verifying templating component" { BeforeAll { - $outPath = (Get-Item -Path 'TestDrive:\').FullName + $outPath = [System.IO.Path]::GetTempPath().Trim("\/") + if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) { $outPath = $env:SYSTEM_DEFAULTWORKINGDIRECTORY.Trim("\/") } $resourcePath = Resolve-PSFPath -Path "$PSScriptRoot\..\resources" $templateName = 'TestTemplate-{0}' -f (Get-Random) } + AfterAll { + Remove-Item -Path "$outPath\Test.txt" -ErrorAction Ignore + } It "Should Record the template correctly" { { New-PSMDTemplate -TemplateName $templateName -FilePath "$resourcePath\þnameþ.txt" -OutPath $outPath -EnableException -ErrorAction Stop } | Should -Not -Throw @@ -27,7 +31,7 @@ It "Should Invoke the template correctly" { { Invoke-PSMDTemplate -TemplateName $templateName -Path $outPath -OutPath $outPath -Name Test -EnableException } | Should -Not -Throw - $content = Get-Content -Path "TestDrive:\Test.txt" -ErrorAction Stop + $content = Get-Content -Path "$outPath\Test.txt" -ErrorAction Stop $values = $content | ConvertFrom-StringData -ErrorAction Stop $values.Name | Should -Be Test $values.Value | Should -Be '123'