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
### Refactor Config Reading During `exec`
This removes the previous workarounds that were required due to tests
setting configs that were not available in the constructor of the
commands.
This also made the fix for nodejs/node#45881
easier since the config checks for workspaces can now all be made in the
command. The fix was to move the package.json detection to
`@npmcli/config` and use that boolean instead of setting
`location=project` which affected all commands such as `config set`
saving to the wrong location.
Some notable changes from this refactor include:
- `execWorkspaces` no longer being passed the raw workspace filters and
instead requiring `this.setWorkspaces()` to be called which was
already being done in most commands
- `static workspaces = [true|false]` on all commands to indicate
workspaces support. This is used in docs generation and whether to
throw when `execWorkspaces` is called or not.
### Drop `fakeMockNpm` and refactor `mockNpm`
This refactor also drops `fakeMockNpm` in favor of `realMockNpm` (now
just `mockNpm`), and adds new features to `mockNpm`.
Some new features of `mockNpm`:
- sets all configs via argv so they are parsed before `npm.load()`. This
is the most important change as it more closely resembles real usage.
- automatically resets `process.exitCode`
- automatically puts global `node_modules` in correct testdir based on platform
- more helpful error messages when used in unsupported ways
- ability to preload a command for execution
- sets `cwd` automatically to `prefix` and sets `globalPrefix` to the
specified testdir
Note that this commit does not include the actual test changes, which
are included in the following commits for readability reasons.
### Linting
This also removes some of the one off linting rules that were set in the
past to reduce churn and fixes all remaining errors.
0 commit comments