Skip to content

Commit

Permalink
feat: implement flag --prefer-dedupe for npm install (#6483)
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rch3n1ng authored May 22, 2023
1 parent 0400ce3 commit 361e194
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Install extends ArboristWorkspaceCmd {
'global-style',
'omit',
'strict-peer-deps',
'prefer-dedupe',
'package-lock',
'foreground-scripts',
'ignore-scripts',
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/config/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,16 @@ define('parseable', {
flatten,
})

define('prefer-dedupe', {
default: false,
type: Boolean,
description: `
Prefer to deduplicate packages if possible, rather than
choosing a newer version of a dependency.
`,
flatten,
})

define('prefer-offline', {
default: false,
type: Boolean,
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/lib/commands/config.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
"package-lock-only": false,
"pack-destination": ".",
"parseable": false,
"prefer-dedupe": false,
"prefer-offline": false,
"prefer-online": false,
"preid": "",
Expand Down Expand Up @@ -265,6 +266,7 @@ package = []
package-lock = true
package-lock-only = false
parseable = false
prefer-dedupe = false
prefer-offline = false
prefer-online = false
; prefix = "{REALGLOBALREFIX}" ; overridden by cli
Expand Down
16 changes: 14 additions & 2 deletions tap-snapshots/test/lib/docs.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,14 @@ For \`list\` this means the output will be based on the tree described by the
Output parseable results from commands that write to standard output. For
\`npm search\`, this will be tab-separated table format.
#### \`prefer-dedupe\`
* Default: false
* Type: Boolean
Prefer to deduplicate packages if possible, rather than choosing a newer
version of a dependency.
#### \`prefer-offline\`
* Default: false
Expand Down Expand Up @@ -1802,6 +1810,7 @@ Array [
"package-lock-only",
"pack-destination",
"parseable",
"prefer-dedupe",
"prefer-offline",
"prefer-online",
"prefix",
Expand Down Expand Up @@ -1938,6 +1947,7 @@ Array [
"package-lock-only",
"pack-destination",
"parseable",
"prefer-dedupe",
"prefer-offline",
"prefer-online",
"preid",
Expand Down Expand Up @@ -2766,7 +2776,7 @@ Options:
[-E|--save-exact] [-g|--global]
[--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
[--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
[--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
[--strict-peer-deps] [--prefer-dedupe] [--no-package-lock] [--foreground-scripts]
[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces] [--include-workspace-root] [--install-links]
Expand All @@ -2789,6 +2799,7 @@ aliases: add, i, in, ins, inst, insta, instal, isnt, isnta, isntal, isntall
#### \`global-style\`
#### \`omit\`
#### \`strict-peer-deps\`
#### \`prefer-dedupe\`
#### \`package-lock\`
#### \`foreground-scripts\`
#### \`ignore-scripts\`
Expand Down Expand Up @@ -2854,7 +2865,7 @@ Options:
[-E|--save-exact] [-g|--global]
[--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
[--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
[--strict-peer-deps] [--no-package-lock] [--foreground-scripts]
[--strict-peer-deps] [--prefer-dedupe] [--no-package-lock] [--foreground-scripts]
[--ignore-scripts] [--no-audit] [--no-bin-links] [--no-fund] [--dry-run]
[-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
[-ws|--workspaces] [--include-workspace-root] [--install-links]
Expand All @@ -2877,6 +2888,7 @@ alias: it
#### \`global-style\`
#### \`omit\`
#### \`strict-peer-deps\`
#### \`prefer-dedupe\`
#### \`package-lock\`
#### \`foreground-scripts\`
#### \`ignore-scripts\`
Expand Down

0 comments on commit 361e194

Please sign in to comment.