Skip to content

Commit d8aeb04

Browse files
🪲 [Fix]: Obay module manifest overrides during tests (#48)
## Description - Fixes #49 ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 10c74d2 commit d8aeb04

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/workflow.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,14 +378,23 @@ jobs:
378378
$path = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "${{ inputs.ModulesOutputPath }}\$moduleName"
379379
$moduleManifestPath = Join-Path -Path $Path -ChildPath "$moduleName.psd1"
380380
381+
# Obay module manifest overrides
382+
$sourcePath = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath "${{ inputs.Path }}"
383+
$sourceModuleManifestPath = Join-Path -Path $sourcePath -ChildPath "manifest.psd1"
384+
if (Test-Path -Path $sourceModuleManifestPath) {
385+
$sourceManifest = Import-PowerShellDataFile -Path $sourceModuleManifestPath
386+
}
387+
381388
$data = [pscustomobject]@{
382389
ModuleName = $moduleName
383390
Path = $path
384391
ModuleManifestPath = $moduleManifestPath
385392
}
386393
Write-Verbose ($data | Format-List | Out-String) -Verbose
387394
388-
Set-ModuleManifest -Path $moduleManifestPath -PowerShellVersion '7.4'
395+
# If the source module manifest has a PowerShellVersion, use that, otherwise use the latest version.
396+
$powerShellVersion = $sourceManifest.PowerShellVersion ?? '7.4'
397+
Set-ModuleManifest -Path $moduleManifestPath -PowerShellVersion $powerShellVersion
389398
390399
Add-ModuleManifestData -Path $moduleManifestPath -CompatiblePSEditions 'Core'
391400
Add-ModuleManifestData -Path $moduleManifestPath -Tags 'PSEdition_Core'
@@ -403,6 +412,10 @@ jobs:
403412
}
404413
}
405414
415+
LogGroup 'Module Manifest - Source' {
416+
Show-FileContent -Path $moduleManifestPath
417+
}
418+
406419
LogGroup 'Module Manifest' {
407420
Show-FileContent -Path $moduleManifestPath
408421
}

tests/srcWithManifest/manifest.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@{
2-
Author = 'Author'
2+
Author = 'Author'
3+
PowerShellVersion = '5.1'
34
}

0 commit comments

Comments
 (0)