Skip to content

refactor: Standardize script entry point pattern across PowerShell scripts #325

@WilliamBerryiii

Description

@WilliamBerryiii

Issue Description

Several scripts use inconsistent patterns for the "direct invocation vs dot-sourced" entry point guard. Some use $MyInvocation.InvocationName -ne '.' while the logic placement varies. Standardizing this pattern would improve consistency and testability across all scripts.

Additional Context

Current variations:

  • Generate-PrReference.ps1: Uses if ($MyInvocation.InvocationName -ne '.') { ... } at the end
  • Get-VerifiedDownload.ps1: Same pattern but with different error handling
  • Package-Extension.ps1: Same pattern with extensive inline logic

Recommended approach:

  1. Ensure all scripts use the same guard pattern at the end of the file
  2. Extract main logic into a named function (e.g., Invoke-*) that the guard calls
  3. Document the pattern in scripts/README.md for future contributors

Testing:

  • Dot-source each script and verify functions are available
  • Run each script directly and verify expected behavior
  • Run existing Pester tests that rely on dot-sourcing

Metadata

Metadata

Labels

documentationImprovements or additions to documentationgood first issueGood for newcomersmaintenanceMaintenance work, no version bump

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions