Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions tests/Manifest.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,15 @@ BeforeAll {
# Parse the version from the changelog
$changelogPath = Join-Path -Path $Env:BHProjectPath -ChildPath 'CHANGELOG.md'
$changelogVersionPattern = '^##\s\\?\[(?<Version>(\d+\.){1,3}\d+)\\?\]' # Matches on a line that starts with '## [Version]' or '## \[Version\]'
$changelogVersion = Get-Content $changelogPath | ForEach-Object {
if ($_ -match $changelogVersionPattern) {
$changelogVersion = $matches.Version
break
}
# Select-String returns the first matching line's named capture directly — no loop and no
# 'break' (which is unreliable inside ForEach-Object, since a pipeline is not a loop).
# Capture the MatchInfo first and guard for no match, so a missing or malformed changelog
# heading leaves $changelogVersion as $null (failing the assertion below cleanly) instead of
# throwing "Cannot index into a null array" here in BeforeAll.
$changelogMatch = Select-String -Path $changelogPath -Pattern $changelogVersionPattern |
Select-Object -First 1
$changelogVersion = if ($changelogMatch) {
$changelogMatch.Matches[0].Groups['Version'].Value
}
}
Describe 'Module manifest' {
Expand Down
Loading