You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli): remove usage of deprecated npm env var from arg parser (#3486)
This removes some code from our argument parsing implementation which
would look for an environment variable (`npm_config_argv`) set by npm
and, if present, merge CLI flags found their into the ones already
present on `process.argv`.
We want to remove this for two reasons:
- `npm_config_argv` is deprecated in `npm` v7+, so in newer versions of the
package manager it is no longer set and our code referencing it is
effectively doing nothing
- `yarn` v1.x still sets it (presumably for compatibility with `npm`
that hasn't been removed yet, which causes an inconsistency between
`npm` and `yarn` where certain `package.json` scripts will run without
issue in `npm` but fail in `yarn` (see #3482)
Accordingly, this commit deletes the offending function from
`src/cli/parse-flags.ts` and makes a few related changes at call sites,
etc which are necessary due to that change.
This commit also refactors the spec file for `parse-flags.ts` to remove
redundant tests. Because all of the supported CLI arguments (i.e. those
added to `knownArgs`) are defined in `ReadonlyArray<string>` variables
we can do a lot of exhaustive testing of all the arguments, set in the
various possible permutations, etc, so we don't need to define a bunch
of individual tests. Accordingly, the test file is refactored to remove
redundant tests, add a few more test cases for the exhaustive tests,
organize things a bit more with `describe` blocks, and ensure that we
have good tests around all off the 'edge-case-ey' things.
0 commit comments