Skip to content

Commit 0c36880

Browse files
Require the latest PowerShell LTS
Declare PowerShell 7.6 so generated module metadata enforces the supported runtime and add deterministic policy coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent f8711c8 commit 0c36880

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/functions/public/Auth/Connect-DomeneshopAccount.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#Requires -Version 7.6
12
#Requires -Modules @{ ModuleName = 'Context'; ModuleVersion = '8.1.6' }
23

34
function Connect-DomeneshopAccount {

tests/ModuleRequirements.Tests.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }
2+
3+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
4+
'PSUseDeclaredVarsMoreThanAssignments', '',
5+
Justification = 'Required for Pester test discovery.'
6+
)]
7+
[CmdletBinding()]
8+
param()
9+
10+
$sourcePath = Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'src'
11+
$testCases = @(
12+
@{
13+
RequiredVersions = @(
14+
Get-ChildItem -Path $sourcePath -Filter '*.ps1' -Recurse -File |
15+
Select-String -Pattern '^\s*#Requires\s+-Version\s+(?<Version>\S+)\s*$' |
16+
ForEach-Object { $_.Matches[0].Groups['Version'].Value } |
17+
Sort-Object -Unique
18+
)
19+
}
20+
)
21+
22+
Describe 'Module requirements' {
23+
It 'targets only the latest PowerShell LTS' -ForEach $testCases {
24+
param($RequiredVersions)
25+
26+
$RequiredVersions | Should -HaveCount 1
27+
$RequiredVersions[0] | Should -Be '7.6'
28+
}
29+
}

0 commit comments

Comments
 (0)