Skip to content

Commit

Permalink
🩹 [Patch]: Add $IsWindows variable in the root module (#52)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
MariusStorhaug authored Apr 13, 2024
1 parent 7b83473 commit 5d13716
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/helpers/Build/Build-PSModuleRootModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ param()
}
#endregion - Module header

#region - $IsWindows
Write-Verbose "Adding variable for `$IsWindows for compatibility with Windows PowerShell."
Add-Content -Path $rootModuleFile -Force -Value @'
if ($PSVersionTable.PSVersion -lt '6.0') {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
'PSAvoidAssignmentToAutomaticVariable', '', Justification = 'Compatibility with PowerShell 6.0 and newer.'
)]
$IsWindows = [System.Environment]::OSVersion.Platform -eq 'Win32NT'
}
'@
#endregion - $IsWindows

#region - Module post-header
Add-Content -Path $rootModuleFile -Force -Value @"
`$scriptName = '$ModuleName'
Expand Down

0 comments on commit 5d13716

Please sign in to comment.