Skip to content

Commit 5d13716

Browse files
🩹 [Patch]: Add $IsWindows variable in the root module (#52)
## Description - Add `$IsWindows` variable in the root module. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [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 7b83473 commit 5d13716

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

scripts/helpers/Build/Build-PSModuleRootModule.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ param()
134134
}
135135
#endregion - Module header
136136

137+
#region - $IsWindows
138+
Write-Verbose "Adding variable for `$IsWindows for compatibility with Windows PowerShell."
139+
Add-Content -Path $rootModuleFile -Force -Value @'
140+
141+
if ($PSVersionTable.PSVersion -lt '6.0') {
142+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
143+
'PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Compatibility with PowerShell 6.0 and newer.'
144+
)]
145+
$IsWindows = [System.Environment]::OSVersion.Platform -eq 'Win32NT'
146+
}
147+
148+
'@
149+
#endregion - $IsWindows
150+
137151
#region - Module post-header
138152
Add-Content -Path $rootModuleFile -Force -Value @"
139153
`$scriptName = '$ModuleName'

0 commit comments

Comments
 (0)