-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: evaluate configs in command class
### 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.
- Loading branch information
1 parent
c52cf6b
commit 450e50f
Showing
78 changed files
with
986 additions
and
923 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,5 @@ | ||
{ | ||
"rules": { | ||
"no-shadow": "off", | ||
"no-console": "error" | ||
}, | ||
"overrides": [{ | ||
"files": [ | ||
"test/**" | ||
], | ||
"rules": { | ||
"no-console": "off" | ||
} | ||
}] | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.