Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2022-03-31 01:37:01 +0300
committerGar <wraithgar@github.com>2022-04-04 21:35:15 +0300
commit2a26e5e21af788f025a5731d88f15f6dc88b4c0c (patch)
tree5a1cc727eba6e9ceee9d50dc9ed9dc2c67ceb81f /lib
parent31a02187a1e0231395ca833f161d6b97ec13f781 (diff)
fix: remove dedupe --save
* Removed dedupe --save documentation and attempted implementation. * Remove some unneeded otplease mocks from test `npm dedupe --save` didn't work in a easy to understand way. It would only update a top level dependency that was duplicated in the tree. Found this out rewriting the dedupe tests to be real. This is not very intuitive and it's best if folks use update or install for saving to package.json.
Diffstat (limited to 'lib')
-rw-r--r--lib/commands/dedupe.js13
-rw-r--r--lib/npm.js3
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/commands/dedupe.js b/lib/commands/dedupe.js
index 4662ce324..96d1ac2ae 100644
--- a/lib/commands/dedupe.js
+++ b/lib/commands/dedupe.js
@@ -12,7 +12,6 @@ class Dedupe extends ArboristWorkspaceCmd {
'legacy-bundling',
'strict-peer-deps',
'package-lock',
- 'save',
'omit',
'ignore-scripts',
'audit',
@@ -29,19 +28,17 @@ class Dedupe extends ArboristWorkspaceCmd {
throw er
}
- // In the context of `npm dedupe` the save
- // config value should default to `false`
- const save = this.npm.config.isDefault('save')
- ? false
- : this.npm.config.get('save')
-
const dryRun = this.npm.config.get('dry-run')
const where = this.npm.prefix
const opts = {
...this.npm.flatOptions,
path: where,
dryRun,
- save,
+ // Saving during dedupe would only update if one of your direct
+ // dependencies was also duplicated somewhere in your tree. It would be
+ // confusing if running this were to also update your package.json. In
+ // order to reduce potential confusion we set this to false.
+ save: false,
workspaces: this.workspaceNames,
}
const arb = new Arborist(opts)
diff --git a/lib/npm.js b/lib/npm.js
index 74825c97c..c819a0807 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -131,6 +131,7 @@ class Npm extends EventEmitter {
const isGlobal = this.config.get('global')
const workspacesEnabled = this.config.get('workspaces')
+ // if cwd is a workspace, the default is set to [that workspace]
const implicitWorkspace = this.config.get('workspace', 'default').length > 0
const workspacesFilters = this.config.get('workspace')
const includeWorkspaceRoot = this.config.get('include-workspace-root')
@@ -138,6 +139,8 @@ class Npm extends EventEmitter {
// or when it is implicit and not in our ignore list
const hasWorkspaceFilters = workspacesFilters.length > 0
const invalidWorkspaceConfig = workspacesEnabled === false && hasWorkspaceFilters
+
+ // (-ws || -w foo) && (cwd is not a workspace || command is not ignoring implicit workspaces)
const filterByWorkspaces = (workspacesEnabled || hasWorkspaceFilters) &&
(!implicitWorkspace || !command.ignoreImplicitWorkspace)
// normally this would go in the constructor, but our tests don't