diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c1069..6b05913 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 header equals the filename. - Task `Generate_Markdown_For_Public_Commands` - Verbose output of the markdown files that was created. +- Task `Generate_Markdown_For_DSC_Resources` + - Outputs a warning message if the old configuration key is used in the + build configuration but keeps using the old configuration key. ### Fixed diff --git a/source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1 b/source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1 index cbfea68..e5de09a 100644 --- a/source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1 +++ b/source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1 @@ -89,7 +89,16 @@ Task Generate_Markdown_For_DSC_Resources { Write-Build -Color 'Magenta' -Text 'Generating Wiki content for all DSC resources based on source and built module.' - $dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources + if ($BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content) + { + Write-Warning -Message 'Build configuration is using the old configuration key ''Generate_Wiki_Content''. Update the build configuration to use the new configuration key ''Generate_Markdown_For_DSC_Resources''' + + $dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content + } + else + { + $dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources + } New-DscResourceWikiPage -SourcePath $SourcePath -BuiltModulePath $builtModuleBase -OutputPath $wikiOutputPath -Metadata $dscResourceMarkdownMetadata -Force } diff --git a/tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1 b/tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1 index b31f9ee..9ad0583 100644 --- a/tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1 +++ b/tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1 @@ -41,7 +41,43 @@ Describe 'Generate_Markdown_For_DSC_Resources' { { $taskParameters = @{ ProjectName = 'DscResource.DocGenerator' - SourcePath = $TestDrive + SourcePath = $TestDrive + } + + Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters + } | Should -Not -Throw + + Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It + } + + It 'Should run the build task with old configuration key without throwing' { + { + $taskParameters = @{ + ProjectName = 'DscResource.DocGenerator' + SourcePath = $TestDrive + BuildInfo = @{ + 'DscResource.DocGenerator' = @{ + Generate_Wiki_Content = @{} + } + } + } + + Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters + } | Should -Not -Throw + + Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It + } + + It 'Should run the build task with new configuration key without throwing' { + { + $taskParameters = @{ + ProjectName = 'DscResource.DocGenerator' + SourcePath = $TestDrive + BuildInfo = @{ + 'DscResource.DocGenerator' = @{ + Generate_Markdown_For_DSC_Resources = @{} + } + } } Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters