Skip to content

Commit 6a4c899

Browse files
committed
Refactor manifest generation to use native -FileList support and update tests to remove invalid manifest checks.
Updated the module manifest generator to rely on New-ModuleManifest’s built‑in -FileList parameter, eliminating the need for post‑processing or custom serialization. Adjusted the associated Pester tests to remove Test-ModuleManifest usage and replace it with Import-PowerShellDataFile, preventing warnings caused by missing module files during scaffolding. All tests now run cleanly with no manifest validation noise.
1 parent 8680d63 commit 6a4c899

3 files changed

Lines changed: 28 additions & 6 deletions

File tree

NewModuleTemplate.psd1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
'New-PesterTests',
2828
'New-PublishScript'
2929
)
30+
FileList = @(
31+
'NewModuleTemplate.psm1',
32+
'NewModuleTemplate.psd1',
33+
'Public',
34+
'Private'
35+
)
36+
3037
AliasesToExport = @()
3138
CmdletsToExport = @()
3239
DscResourcesToExport = @()

Public/New-ModuleManifestFile.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ function New-ModuleManifestFile {
5757
-FunctionsToExport @() `
5858
-AliasesToExport @() `
5959
-CompatiblePSEditions @('Core', 'Desktop') `
60-
-PowerShellVersion '5.1' | Out-Null
60+
-PowerShellVersion '5.1' `
61+
-FileList @(
62+
"$Name.psm1",
63+
"$Name.psd1",
64+
"Public",
65+
"Private"
66+
) | Out-Null
6167

6268
Write-Information "Module manifest created at '$manifestPath'."
6369

Tests/New-ModuleManifestFile.Tests.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,26 @@ Describe "New-ModuleManifestFile" {
2121
It "Generates a unique GUID" {
2222
$manifestPath = New-ModuleManifestFile -ModulePath $TempRoot -Name "TestModule"
2323

24-
$data = Test-ModuleManifest -Path $manifestPath
24+
$data = Import-PowerShellDataFile $manifestPath
2525

2626
# GUID should be non-empty and valid
2727
{ [guid]::Parse($data.Guid) } | Should -Not -Throw
2828
}
2929

30-
It "Manifest imports without error" {
30+
It "Includes only the expected FileList entries" {
3131
$manifestPath = New-ModuleManifestFile -ModulePath $TempRoot -Name "TestModule"
3232

33-
{
34-
Import-Module $manifestPath -Force
35-
} | Should -Not -Throw
33+
$data = Import-PowerShellDataFile $manifestPath
34+
35+
$data.FileList | Should -Contain "TestModule.psm1"
36+
$data.FileList | Should -Contain "TestModule.psd1"
37+
$data.FileList | Should -Contain "Public"
38+
$data.FileList | Should -Contain "Private"
39+
40+
# Ensure no unexpected folders are included
41+
$data.FileList | Should -Not -Contain "Docs"
42+
$data.FileList | Should -Not -Contain "Tests"
43+
$data.FileList | Should -Not -Contain "Scripts"
44+
$data.FileList | Should -Not -Contain "Analyzer"
3645
}
3746
}

0 commit comments

Comments
 (0)