Rename Pester.ps1 script-scope helper to Pester.ScriptScope.ps1#2832
Merged
Conversation
PSResourceGet decides whether an installed package is a script by checking for a <ModuleName>.ps1 file in the package root. Pester shipped a Pester.ps1 (used by Invoke-InNewScriptScope for script-scope isolation), so installing Pester with Install-PSResource printed a spurious "installation path for the script does not currently appear in PATH" warning. Rename the file to Pester.ScriptScope.ps1 so it no longer matches the module name, update the runtime reference, the build copy step and the published file list, and add a regression test asserting the shipped module never contains a Pester.ps1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Installing Pester with
Install-PSResource Pesterprints a spurious warning:Root cause
PSResourceGet decides whether an installed package is a script by checking for a
<ModuleName>.ps1file in the package root (InstallHelper.cs):Pester ships a tiny
Pester.ps1(used byInvoke-InNewScriptScopefor script-scope isolation), soisScriptbecomestrueand the PATH warning atif (!_savePkg && isScript)fires. The upstream fix in PSResourceGet#1043 wasn't accepted, so the agreed fallback is to rename the file on Pester's side.Fix
Rename
src/Pester.ps1→src/Pester.ScriptScope.ps1so the shipped module no longer contains a file matching the module name, and update its references:src/Pester.Runtime.ps1— theInvoke-InNewScriptScopepathbuild.ps1— the copy-to-bin/steppublish/filesToPublish.ps1— the published-file listThe file must stay a standalone
.ps1on disk (it is invoked as a real script to push a new script scope; it is not inlined intoPester.psm1). A comment in the file and at the call site documents why it must not be namedPester.ps1.Regression test
Added a
StyleRules-tagged test intst/Pester.Tests.ps1asserting the built module shipsPester.ScriptScope.ps1and contains noPester.ps1.Verification
bin/shipsPester.ScriptScope.ps1and noPester.ps1.Invoke-InNewScriptScopeand passes (script scope pushed,$PSCommandPathset)../src: no new violations (new file is clean).Fix #2826