diff --git a/PSScriptAnalyzerSettings.psd1 b/PSScriptAnalyzerSettings.psd1 index 305b6cc..3e13bca 100644 --- a/PSScriptAnalyzerSettings.psd1 +++ b/PSScriptAnalyzerSettings.psd1 @@ -2,5 +2,6 @@ ExcludeRules = @( 'PSUseShouldProcessForStateChangingFunctions' 'PSUseSingularNouns' + 'PSUseApprovedVerbs' ) } diff --git a/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 b/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 index 7974da9..714d875 100644 --- a/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 +++ b/Tests/Unit/Private/Resolve-ModuleSourcePaths.Tests.ps1 @@ -112,7 +112,8 @@ Describe 'Resolve-ModuleSourcePaths' { # Create only a Public dir, no Enums/Classes/Private New-Item -Path (Join-Path $TempRoot 'Public') -ItemType Directory -Force | Out-Null - Set-Content -Path (Join-Path $TempRoot 'Public' 'Test-Func.ps1') -Value 'function Test-Func { }' + $PublicDir = Join-Path -Path $TempRoot -ChildPath 'Public' + Set-Content -Path (Join-Path -Path $PublicDir -ChildPath 'Test-Func.ps1') -Value 'function Test-Func { }' $Result = Resolve-ModuleSourcePaths -ModuleRoot $TempRoot } diff --git a/Tests/Unit/Private/Update-ManifestField.Tests.ps1 b/Tests/Unit/Private/Update-ManifestField.Tests.ps1 index 229b1f4..a10b65c 100644 --- a/Tests/Unit/Private/Update-ManifestField.Tests.ps1 +++ b/Tests/Unit/Private/Update-ManifestField.Tests.ps1 @@ -161,9 +161,19 @@ Describe 'Update-ManifestField' { BeforeEach { # Create a fresh copy for each test Copy-Item -Path $Script:RefManifestPath -Destination $Script:PrereleaseManifestPath -Force - # Uncomment the Prerelease field so Update-ManifestField can locate and replace it + # Ensure the Prerelease field exists and is uncommented. + # PS 5.1 New-ModuleManifest may not generate the Prerelease field at all. $Content = [System.IO.File]::ReadAllText($Script:PrereleaseManifestPath, [System.Text.Encoding]::UTF8) - $Content = $Content -replace '# Prerelease = ''''', 'Prerelease = ''''' + if ($Content -match '# Prerelease = ') { + # PS 7+: uncomment the existing field + $Content = $Content -replace '# Prerelease = ''''', 'Prerelease = ''''' + } + elseif ($Content -notmatch '\bPrerelease\s*=') { + # PS 5.1: field missing entirely, inject into PSData section + $PsdMarker = ' } # End of PSData hashtable' + $Injection = " Prerelease = ''" + "`r`n" + "`r`n" + $PsdMarker + $Content = $Content.Replace($PsdMarker, $Injection) + } [System.IO.File]::WriteAllText($Script:PrereleaseManifestPath, $Content, [System.Text.UTF8Encoding]::new($true)) }