-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(powershell): use Invoke-Expression to pass args #8267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: latest
Are you sure you want to change the base?
Conversation
Co-authored-by: noseratio <[email protected]>
Hi Alex, Any change here should go along with new tests that prove what's not working (before the change) but working after. This includes executing I have updated Please include this in the PR. On my machine (pwsh 7.5.0, npm 10.9.2), all parameters are passed correctly with the current Do you have other tests that fail? Please add them. |
…ipts Co-authored-by: @mbtools
@mbtools thanks! I'll work on new tests for this PR later today |
|
This PR is ready for review |
Below "Output" is from running the This should pass before adding my PR changes @mbtools Ok I have an issue running the tests on my Windows machine Without my PR, running line number 240 and line number 253 from https://github.com/npm/cli/blob/latest/test/bin/windows-shims.js
|
This is not the same Your Log: |
Right...I meant I'm getting 2 failing tests before adding my PR |
That's with Windows PowerShell? I'm not sure if this ever was an option (or tested). Here it's about cmd, pwsh, and bash. If we can make it work for the older Windows PowerShell as well, why not? |
My 2c. If it's possible to make it work for both legacy (v5.0 and below) and modern (v6+) PowerShell with little efforts, that's great. Otherwise, I'd say specifying |
I manually tested that |
the 2 failing tests I get on my machine do not appear in GitHub Actions CI so it must be my setup issue |
it's bizarre
For both Windows PowerShell and pwsh7, doing
|
Converted to a draft..... this will fail the scenario in Windows PowerShell {
bin: 'npm',
params: ['test -- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'],
expected: `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`
}, |
Modifed the code to try to replicate $MyInvocation.Statement on Windows PowerShell |
I was afraid of this slight mess... Here's how And here we are again... Calling I know you're interested in getting Windows PowerShell to work. Can we get back to the primary goal to solve issues with passing named parameters to PowerShell7 ( |
OK @mbtools, I'm all done. Let me know what you think of it |
This is goodWe are closer than ever 👍 Maybe we can combine some test cases. I used this one:
Not so goodThe solution fails if there are spaces in the path to The full expression looks like this:
It does need the quoting 😉 |
Thanks for the feedback! I'll look into the not so good part tomorrow I also just made the ps1 files simpler by going back to the old logic if the grave key is found in the command....too many edge cases with that one |
Ok this PR looks complete to me, but if there's anything else to change please let me know |
Letting CI run. Will let @mbtools weigh in here before landing. Node 24 is now live with npm 11 so it will be good to get this landed. |
Reopening of #7458