Skip to content

Fix output path helper parameters#274

Open
SamErde wants to merge 1 commit intomainfrom
samerde/fix-output-path-helper
Open

Fix output path helper parameters#274
SamErde wants to merge 1 commit intomainfrom
samerde/fix-output-path-helper

Conversation

@SamErde
Copy link
Copy Markdown
Collaborator

@SamErde SamErde commented May 6, 2026

Summary

Fixes correctness and style issues in New-OutputPath, a private helper function that creates per-forest output directories.

Changes

Private/New-OutputPath.ps1

  • Add declared parameters: $Targets and $OutputPath were missing from the param() block; the function previously relied on ambient scope variables, which is fragile and undocumented.
  • Replace string concatenation: Replaced $OutputPath + "\" + $forest with Join-Path -Path $OutputPath -ChildPath $forest for cross-platform correctness.
  • Activate ShouldProcess: SupportsShouldProcess was declared in CmdletBinding but $PSCmdlet.ShouldProcess() was never called; added the guard so -WhatIf/-Confirm work correctly.

Invoke-Locksmith.ps1 (monolithic)

  • Mirrors the same fix per repository convention (the monolithic file is committed and manually kept in sync with source, as evidenced by prior commits).

Notes

  • New-OutputPath is currently dead code (no call sites exist in the module), but it is loaded by the build pipeline and should be correct.
  • No behavioral change for existing callers; parameters are additive.
  • PSScriptAnalyzer reports no warnings or errors on the changed file.
  • No Pester tests added (out of scope per task definition).

- Declare Targets and OutputPath as mandatory parameters instead of
  relying on ambient scope variables.
- Replace string concatenation with Join-Path for cross-platform
  correctness and readability.
- Add ShouldProcess guard so -WhatIf and -Confirm behave correctly.
- Mirror same fix in the generated monolithic Invoke-Locksmith.ps1.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SamErde SamErde marked this pull request as ready for review May 6, 2026 09:24
Copilot AI review requested due to automatic review settings May 6, 2026 09:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects and hardens the internal New-OutputPath helper that creates per-forest output directories, ensuring it no longer relies on ambient variables and properly honors -WhatIf/-Confirm.

Changes:

  • Adds explicit, mandatory Targets and OutputPath parameters to New-OutputPath (previously relied on $Targets/$OutputPath from outer scope).
  • Replaces manual path concatenation with Join-Path for more robust path construction.
  • Activates SupportsShouldProcess behavior by guarding directory creation with $PSCmdlet.ShouldProcess(...).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Private/New-OutputPath.ps1 Makes the helper self-contained (declared parameters), uses Join-Path, and enables -WhatIf/-Confirm via ShouldProcess.
Invoke-Locksmith.ps1 Mirrors the same New-OutputPath corrections in the monolithic script version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@SamErde SamErde marked this pull request as draft May 6, 2026 09:27
@SamErde SamErde marked this pull request as ready for review May 6, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants