Content-Length: 310621 | pFad | http://github.com/npm/cli/pull/8539

33 fix(powershell): improve argument parsing by alexsch01 · Pull Request #8539 · npm/cli · GitHub
Skip to content

Conversation

alexsch01
Copy link
Contributor

@alexsch01 alexsch01 commented Aug 28, 2025

improve the argument parsing PS1 logic

  • support & npm args and . npm args properly
  • support syntax such as C:\"Program Files"\nodejs\npm.ps1 args

of course ^ for both npm and npx version of the script

Code Explanation: instead of getting the CommandElements.Extent.Text array and joining it with spaces right away, now it's getting the same array and only capturing everything after the first element


@wraithgar @mbtools sorry about this right after the other PR

@alexsch01 alexsch01 requested a review from a team as a code owner August 28, 2025 18:36
@alexsch01 alexsch01 marked this pull request as draft August 28, 2025 18:52
@alexsch01 alexsch01 marked this pull request as ready for review August 28, 2025 19:04
@alexsch01
Copy link
Contributor Author

OK PR is ready now

@mbtools
Copy link
Contributor

mbtools commented Aug 28, 2025

C:\"Program Files"\nodejs\npm.ps1 is crappy style. "C:\Program Files\nodejs\npm.ps1" is the way to do it. But if it's valid, fine.

We're getting more cases that aren't covered by tests. However, the Windows Shims Test is already taking over 7 min. It loops over 7 shells (times 6 tests). Either the test itself needs a performance improvement, or we should have a separate test just for PowerShell that covers the recently added cases.

@alexsch01
Copy link
Contributor Author

C:\"Program Files"\nodejs\npm.ps1 is crappy style. "C:\Program Files\nodejs\npm.ps1" is the way to do it. But if it's valid, fine.

The first one is required if you don't want to include the call (&) operator

It's also better code in this PR since we used to assume InvocationName was always in the command and that isn't true

@mbtools
Copy link
Contributor

mbtools commented Aug 29, 2025

looks good

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








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/npm/cli/pull/8539

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy