Commit a01a711
Replace null-coalescing operators with PS5.1-compatible syntax (#443)
Plaster v2.0.0-alpha uses the null-coalescing operator (`??`) introduced
in PowerShell 7.0, breaking compatibility with PowerShell 5.1 as
specified in the module manifest.
## Changes
**Write-PlasterLog.ps1**
- Replaced `??` operators with conditional expressions compatible with
PS5.1+
```powershell
# Before
$currentLogLevel = $script:LogLevel ?? 'Information'
$currentLevelValue = $logLevels[$currentLogLevel] ?? 2
# After
$currentLogLevel = if ($null -ne $script:LogLevel) { $script:LogLevel } else { 'Information' }
$currentLevelValue = if ($null -ne $logLevels[$currentLogLevel]) { $logLevels[$currentLogLevel] } else { 2 }
```
**Plaster.psm1**
- Added dot-sourcing for Private and Public function files
- Implemented selective export of public functions only
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `www.powershellgallery.com`
> - Triggering command: `/usr/bin/pwsh pwsh -NoProfile -File ./build.ps1
-Bootstrap` (dns block)
> - Triggering command: `/usr/bin/pwsh pwsh -NoProfile -Command
Register-PSRepository -Default -ErrorAction SilentlyContinue
Get-PSRepository` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/PowerShellOrg/Plaster/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Plaster v2.0.0-alpha broken on Windows</issue_title>
> <issue_description>Hiya,
>
> [Sampler]() uses Plaster and we've noticed on our pipelines that the
prerelease version breaks on windows because `Write-PlasterLog` uses the
Null-coalescing operator.
>
>
https://github.com/PowerShellOrg/Plaster/blob/v2/Plaster/Private/Write-PlasterLog.ps1#L52-L54
>
> Could you please fix soonish, or would you recommend we pin an old
version?</issue_description>
>
> <agent_instructions>Search for any use of null coalescing and remove
it. This module must be able to run PS5.1</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #442
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: HeyItsGilbert <615265+HeyItsGilbert@users.noreply.github.com>
Co-authored-by: Gilbert Sanchez <me@gilbertsanchez.com>1 parent 00a42e0 commit a01a711
File tree
4 files changed
+17
-7
lines changed- Plaster
- Private
- tests
4 files changed
+17
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
9 | 17 | | |
10 | 18 | | |
11 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
0 commit comments