Skip to content

Commit c46ebaf

Browse files
🩹 [Refactor]: Rearrange header content addition in Build-PSModuleRootModule.ps1 for improved clarity and structure
1 parent 0a21646 commit c46ebaf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

‎scripts/helpers/Build/Build-PSModuleRootModule.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,7 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
134134
#endregion - Analyze source files
135135

136136
#region - Module header
137-
$headerFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath 'header.ps1'
138-
if (Test-Path -Path $headerFilePath) {
139-
Get-Content -Path $headerFilePath -Raw | Add-Content -Path $rootModuleFile -Force
140-
$headerFilePath | Remove-Item -Force
141-
} else {
142-
Add-Content -Path $rootModuleFile -Force -Value @'
137+
Add-Content -Path $rootModuleFile -Force -Value @'
143138
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
144139
'PSAvoidAssignmentToAutomaticVariable', 'IsWindows',
145140
Justification = 'IsWindows doesnt exist in PS5.1'
@@ -148,6 +143,14 @@ $MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
148143
'PSUseDeclaredVarsMoreThanAssignments', 'IsWindows',
149144
Justification = 'IsWindows doesnt exist in PS5.1'
150145
)]
146+
'@
147+
148+
$headerFilePath = Join-Path -Path $ModuleOutputFolder -ChildPath 'header.ps1'
149+
if (Test-Path -Path $headerFilePath) {
150+
Get-Content -Path $headerFilePath -Raw | Add-Content -Path $rootModuleFile -Force
151+
$headerFilePath | Remove-Item -Force
152+
} else {
153+
Add-Content -Path $rootModuleFile -Force -Value @'
151154
[CmdletBinding()]
152155
param()
153156
'@

0 commit comments

Comments
 (0)