Skip to content

Commit 02e340b

Browse files
authored
Update task Generate_Markdown_For_DSC_Resources to use old config key (#162)
1 parent 66b21b9 commit 02e340b

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
header equals the filename.
4040
- Task `Generate_Markdown_For_Public_Commands`
4141
- Verbose output of the markdown files that was created.
42+
- Task `Generate_Markdown_For_DSC_Resources`
43+
- Outputs a warning message if the old configuration key is used in the
44+
build configuration but keeps using the old configuration key.
4245

4346
### Fixed
4447

source/tasks/Generate_Markdown_For_DSC_Resources.build.ps1

+10-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,16 @@ Task Generate_Markdown_For_DSC_Resources {
8989

9090
Write-Build -Color 'Magenta' -Text 'Generating Wiki content for all DSC resources based on source and built module.'
9191

92-
$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources
92+
if ($BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content)
93+
{
94+
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'''
95+
96+
$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Wiki_Content
97+
}
98+
else
99+
{
100+
$dscResourceMarkdownMetadata = $BuildInfo.'DscResource.DocGenerator'.Generate_Markdown_For_DSC_Resources
101+
}
93102

94103
New-DscResourceWikiPage -SourcePath $SourcePath -BuiltModulePath $builtModuleBase -OutputPath $wikiOutputPath -Metadata $dscResourceMarkdownMetadata -Force
95104
}

tests/unit/tasks/Generate_Markdown_For_DSC_Resources.Tests.ps1

+37-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,43 @@ Describe 'Generate_Markdown_For_DSC_Resources' {
4141
{
4242
$taskParameters = @{
4343
ProjectName = 'DscResource.DocGenerator'
44-
SourcePath = $TestDrive
44+
SourcePath = $TestDrive
45+
}
46+
47+
Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters
48+
} | Should -Not -Throw
49+
50+
Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It
51+
}
52+
53+
It 'Should run the build task with old configuration key without throwing' {
54+
{
55+
$taskParameters = @{
56+
ProjectName = 'DscResource.DocGenerator'
57+
SourcePath = $TestDrive
58+
BuildInfo = @{
59+
'DscResource.DocGenerator' = @{
60+
Generate_Wiki_Content = @{}
61+
}
62+
}
63+
}
64+
65+
Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters
66+
} | Should -Not -Throw
67+
68+
Assert-MockCalled -CommandName New-DscResourceWikiPage -Exactly -Times 1 -Scope It
69+
}
70+
71+
It 'Should run the build task with new configuration key without throwing' {
72+
{
73+
$taskParameters = @{
74+
ProjectName = 'DscResource.DocGenerator'
75+
SourcePath = $TestDrive
76+
BuildInfo = @{
77+
'DscResource.DocGenerator' = @{
78+
Generate_Markdown_For_DSC_Resources = @{}
79+
}
80+
}
4581
}
4682

4783
Invoke-Build -Task $buildTaskName -File $script:buildScript.Definition @taskParameters

0 commit comments

Comments
 (0)