Skip to content

Commit 3b24123

Browse files
Fix null-coalescing operator for PS5.1 compatibility
Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>
1 parent c6ce63d commit 3b24123

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

Plaster/Plaster.psm1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,27 @@ if (-not (Get-Variable -Name 'JsonSchemaVersion' -Scope Script -ErrorAction Sile
159159
# Export the variables that need to be available globally
160160
Export-ModuleMember -Variable @('TargetNamespace', 'DefaultEncoding', 'JsonSchemaVersion')
161161

162+
# Dot source private functions
163+
$privateFiles = Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue
164+
foreach ($file in $privateFiles) {
165+
. $file.FullName
166+
}
167+
168+
# Dot source public functions
169+
$publicFiles = Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue
170+
$publicFunctionNames = @()
171+
foreach ($file in $publicFiles) {
172+
. $file.FullName
173+
# Get the function name from the file (assumes filename matches function name)
174+
$functionName = $file.BaseName
175+
$publicFunctionNames += $functionName
176+
}
177+
178+
# Export only public functions
179+
if ($publicFunctionNames.Count -gt 0) {
180+
Export-ModuleMember -Function $publicFunctionNames
181+
}
182+
162183
# Module cleanup on removal
163184
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
164185
Write-PlasterLog -Level Information -Message "Plaster module is being removed"

Plaster/Private/Write-PlasterLog.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ function Write-PlasterLog {
4949
'Debug' = 4
5050
}
5151

52-
$currentLogLevel = $script:LogLevel ?? 'Information'
53-
$currentLevelValue = $logLevels[$currentLogLevel] ?? 2
54-
$messageLevelValue = $logLevels[$Level] ?? 2
52+
$currentLogLevel = if ($null -ne $script:LogLevel) { $script:LogLevel } else { 'Information' }
53+
$currentLevelValue = if ($null -ne $logLevels[$currentLogLevel]) { $logLevels[$currentLogLevel] } else { 2 }
54+
$messageLevelValue = if ($null -ne $logLevels[$Level]) { $logLevels[$Level] } else { 2 }
5555

5656
if ($messageLevelValue -gt $currentLevelValue) {
5757
return

0 commit comments

Comments
 (0)