Context and request
examples/General.ps1 hardcodes POSIX paths throughout — /tmp/config.json, /tmp/user-data.json, /tmp/user-settings.json, /tmp/users-pipeline.json, /tmp/user-export.json, /tmp/service-config.json, /tmp/original-config.json, /tmp/modified-config.json — so every file-based example fails on Windows. The module is tested on a three-OS matrix and published to users on all three platforms.
The file also demonstrates behaviour that is being corrected elsewhere. Example 18 performs an import, modify, export round-trip and prints the result; with the current _SourceFile injection that round-trip writes an extra property into the output file, so the example teaches the defect as if it were intended. Example 9 prints $importedConfig._SourceFile explicitly.
examples/ is where realistic end-to-end scenarios live, so these need to be correct, not merely illustrative.
Acceptance criteria.
examples/General.ps1 runs to completion on Linux, macOS, and Windows.
- No absolute POSIX path is hardcoded anywhere in the file.
- Every temporary file the script creates is removed when it finishes, including on the error paths.
- No example depends on
_SourceFile or any other behaviour scheduled for removal.
- The examples reflect realistic user scenarios rather than restating command help.
Technical decisions
Temporary paths use [System.IO.Path]::GetTempPath() combined with Join-Path, which resolves correctly on all three platforms, rather than $env:TEMP — which is unset on Linux and macOS.
The _SourceFile references are removed rather than updated. That property is being removed from Import-Json, so an example that prints it will break; leaving it and fixing it later means shipping a knowingly broken example in the interim.
This depends on the _SourceFile correction landing first, so the round-trip example can be verified against the corrected behaviour rather than written speculatively.
Cleanup moves into a finally block so temporary files do not survive a mid-script failure.
examples/ does not match ImportantFilePatterns, so this does not trigger a module build or release on its own.
Implementation plan
Context and request
examples/General.ps1hardcodes POSIX paths throughout —/tmp/config.json,/tmp/user-data.json,/tmp/user-settings.json,/tmp/users-pipeline.json,/tmp/user-export.json,/tmp/service-config.json,/tmp/original-config.json,/tmp/modified-config.json— so every file-based example fails on Windows. The module is tested on a three-OS matrix and published to users on all three platforms.The file also demonstrates behaviour that is being corrected elsewhere. Example 18 performs an import, modify, export round-trip and prints the result; with the current
_SourceFileinjection that round-trip writes an extra property into the output file, so the example teaches the defect as if it were intended. Example 9 prints$importedConfig._SourceFileexplicitly.examples/is where realistic end-to-end scenarios live, so these need to be correct, not merely illustrative.Acceptance criteria.
examples/General.ps1runs to completion on Linux, macOS, and Windows._SourceFileor any other behaviour scheduled for removal.Technical decisions
Temporary paths use
[System.IO.Path]::GetTempPath()combined withJoin-Path, which resolves correctly on all three platforms, rather than$env:TEMP— which is unset on Linux and macOS.The
_SourceFilereferences are removed rather than updated. That property is being removed fromImport-Json, so an example that prints it will break; leaving it and fixing it later means shipping a knowingly broken example in the interim.This depends on the
_SourceFilecorrection landing first, so the round-trip example can be verified against the corrected behaviour rather than written speculatively.Cleanup moves into a
finallyblock so temporary files do not survive a mid-script failure.examples/does not matchImportantFilePatterns, so this does not trigger a module build or release on its own.Implementation plan
/tmppaths withJoin-Path ([System.IO.Path]::GetTempPath()) '<name>'_SourceFilereferences from Example 9 and the round-trip in Example 18finallyblock