| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5fe7cfa commit 4b174ce
53 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,12 @@ result in new modules being installed. | |||
| 72 | 72 | ||
| 73 | 73 | Using `npm find-dupes` will run the command in `--dry-run` mode. | |
| 74 | 74 | ||
| 75 | + Note that by default `npm dedupe` will not update the semver values of direct | ||
| 76 | + dependencies in your project `package.json`, if you want to also update | ||
| 77 | + values in `package.json` you can run: `npm dedupe --save` (or add the | ||
| 78 | + `save=true` option to a [configuration file](/configuring-npm/npmrc) | ||
| 79 | + to make that the default behavior). | ||
| 80 | + | ||
| 75 | 81 | ### Configuration | |
| 76 | 82 | ||
| 77 | 83 | <!-- AUTOGENERATED CONFIG DESCRIPTIONS START --> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,12 @@ packages. | |||
| 27 | 27 | If no package name is specified, all packages in the specified location (global | |
| 28 | 28 | or local) will be updated. | |
| 29 | 29 | ||
| 30 | + Note that by default `npm update` will not update the semver values of direct | ||
| 31 | + dependencies in your project `package.json`, if you want to also update | ||
| 32 | + values in `package.json` you can run: `npm update --save` (or add the | ||
| 33 | + `save=true` option to a [configuration file](/configuring-npm/npmrc) | ||
| 34 | + to make that the default behavior). | ||
| 35 | + | ||
| 30 | 36 | ### Example | |
| 31 | 37 | ||
| 32 | 38 | For the examples below, assume that the current package is `app` and it depends | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1326,13 +1326,16 @@ The base URL of the npm registry. | |||
| 1326 | 1326 | ||
| 1327 | 1327 | #### `save` | |
| 1328 | 1328 | ||
| 1329 | - * Default: true | ||
| 1329 | + * Default: `true` unless when using `npm update` or `npm dedupe` where it | ||
| 1330 | + defaults to `false` | ||
| 1330 | 1331 | * Type: Boolean | |
| 1331 | 1332 | ||
| 1332 | - Save installed packages to a package.json file as dependencies. | ||
| 1333 | + Save installed packages to a `package.json` file as dependencies. | ||
| 1333 | 1334 | ||
| 1334 | 1335 | When used with the `npm rm` command, removes the dependency from | |
| 1335 | - package.json. | ||
| 1336 | + `package.json`. | ||
| 1337 | + | ||
| 1338 | + Will also prevent writing to `package-lock.json` if set to `false`. | ||
| 1336 | 1339 | ||
| 1337 | 1340 | <!-- automatically generated, do not edit manually --> | |
| 1338 | 1341 | <!-- see lib/utils/config/definitions.js --> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,6 +192,11 @@ <h3 id="description">Description</h3> | |||
| 192 | 192 | <p>Note that this operation transforms the dependency tree, but will never | |
| 193 | 193 | result in new modules being installed.</p> | |
| 194 | 194 | <p>Using <code>npm find-dupes</code> will run the command in <code>--dry-run</code> mode.</p> | |
| 195 | + <p>Note that by default <code>npm dedupe</code> will not update the semver values of direct | ||
| 196 | + dependencies in your project <code>package.json</code>, if you want to also update | ||
| 197 | + values in <code>package.json</code> you can run: <code>npm dedupe --save</code> (or add the | ||
| 198 | + <code>save=true</code> option to a <a href="../configuring-npm/npmrc.html">configuration file</a> | ||
| 199 | + to make that the default behavior).</p> | ||
| 195 | 200 | <h3 id="configuration">Configuration</h3> | |
| 196 | 201 | <!-- raw HTML omitted --> | |
| 197 | 202 | <!-- raw HTML omitted --> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,7 +160,7 @@ <h3 id="description">Description</h3> | |||
| 160 | 160 | the results to only the paths to the packages named. Note that nested | |
| 161 | 161 | packages will <em>also</em> show the paths to the specified packages. For | |
| 162 | 162 | example, running <code>npm ls promzard</code> in npm's source tree will show:</p> | |
| 163 | - <pre lang="bash"><code>npm@8.3.1 /path/to/npm | ||
| 163 | + <pre lang="bash"><code>npm@8.3.2 /path/to/npm | ||
| 164 | 164 | └─┬ init-package-json@0.0.4 | |
| 165 | 165 | └── promzard@0.1.5 | |
| 166 | 166 | </code></pre> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -160,6 +160,11 @@ <h3 id="description">Description</h3> | |||
| 160 | 160 | packages.</p> | |
| 161 | 161 | <p>If no package name is specified, all packages in the specified location (global | |
| 162 | 162 | or local) will be updated.</p> | |
| 163 | + <p>Note that by default <code>npm update</code> will not update the semver values of direct | ||
| 164 | + dependencies in your project <code>package.json</code>, if you want to also update | ||
| 165 | + values in <code>package.json</code> you can run: <code>npm update --save</code> (or add the | ||
| 166 | + <code>save=true</code> option to a <a href="../configuring-npm/npmrc.html">configuration file</a> | ||
| 167 | + to make that the default behavior).</p> | ||
| 163 | 168 | <h3 id="example">Example</h3> | |
| 164 | 169 | <p>For the examples below, assume that the current package is <code>app</code> and it depends | |
| 165 | 170 | on dependencies, <code>dep1</code> (<code>dep2</code>, .. etc.). The published versions of <code>dep1</code> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -149,7 +149,7 @@ <h2 id="table-of-contents">Table of contents</h2> | |||
| 149 | 149 | <pre lang="bash"><code>npm <command> [args] | |
| 150 | 150 | </code></pre> | |
| 151 | 151 | <h3 id="version">Version</h3> | |
| 152 | - <p>8.3.1</p> | ||
| 152 | + <p>8.3.2</p> | ||
| 153 | 153 | <h3 id="description">Description</h3> | |
| 154 | 154 | <p>npm is the package manager for the Node JavaScript platform. It puts | |
| 155 | 155 | modules in place so that node can find them, and manages dependency | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1210,12 +1210,14 @@ <h4 id="registry"><code>registry</code></h4> | |||
| 1210 | 1210 | <!-- raw HTML omitted --> | |
| 1211 | 1211 | <h4 id="save"><code>save</code></h4> | |
| 1212 | 1212 | <ul> | |
| 1213 | - <li>Default: true</li> | ||
| 1213 | + <li>Default: <code>true</code> unless when using <code>npm update</code> or <code>npm dedupe</code> where it | ||
| 1214 | + defaults to <code>false</code></li> | ||
| 1214 | 1215 | <li>Type: Boolean</li> | |
| 1215 | 1216 | </ul> | |
| 1216 | - <p>Save installed packages to a package.json file as dependencies.</p> | ||
| 1217 | + <p>Save installed packages to a <code>package.json</code> file as dependencies.</p> | ||
| 1217 | 1218 | <p>When used with the <code>npm rm</code> command, removes the dependency from | |
| 1218 | - package.json.</p> | ||
| 1219 | + <code>package.json</code>.</p> | ||
| 1220 | + <p>Will also prevent writing to <code>package-lock.json</code> if set to <code>false</code>.</p> | ||
| 1219 | 1221 | <!-- raw HTML omitted --> | |
| 1220 | 1222 | <!-- raw HTML omitted --> | |
| 1221 | 1223 | <h4 id="save-bundle"><code>save-bundle</code></h4> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,7 @@ | |||
| 1 | 1 | // Base class for npm commands | |
| 2 | + | ||
| 3 | + const { relative } = require('path') | ||
| 4 | + | ||
| 2 | 5 | const usageUtil = require('./utils/usage.js') | |
| 3 | 6 | const ConfigDefinitions = require('./utils/config/definitions.js') | |
| 4 | 7 | const getWorkspaces = require('./workspaces/get-workspaces.js') | |
@@ -78,9 +81,14 @@ class BaseCommand { | |||
| 78 | 81 | this.includeWorkspaceRoot = false | |
| 79 | 82 | } | |
| 80 | 83 | ||
| 84 | + const relativeFrom = relative(this.npm.localPrefix, process.cwd()).startsWith('..') | ||
| 85 | + ? this.npm.localPrefix | ||
| 86 | + : process.cwd() | ||
| 87 | + | ||
| 81 | 88 | const ws = await getWorkspaces(filters, { | |
| 82 | 89 | path: this.npm.localPrefix, | |
| 83 | 90 | includeWorkspaceRoot: this.includeWorkspaceRoot, | |
| 91 | + relativeFrom, | ||
| 84 | 92 | }) | |
| 85 | 93 | this.workspaces = ws | |
| 86 | 94 | this.workspaceNames = [...ws.keys()] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ class Dedupe extends ArboristWorkspaceCmd { | |||
| 13 | 13 | 'legacy-bundling', | |
| 14 | 14 | 'strict-peer-deps', | |
| 15 | 15 | 'package-lock', | |
| 16 | + 'save', | ||
| 16 | 17 | 'omit', | |
| 17 | 18 | 'ignore-scripts', | |
| 18 | 19 | 'audit', | |
@@ -29,13 +30,20 @@ class Dedupe extends ArboristWorkspaceCmd { | |||
| 29 | 30 | throw er | |
| 30 | 31 | } | |
| 31 | 32 | ||
| 33 | + // In the context of `npm dedupe` the save | ||
| 34 | + // config value should default to `false` | ||
| 35 | + const save = this.npm.config.isDefault('save') | ||
| 36 | + ? false | ||
| 37 | + : this.npm.config.get('save') | ||
| 38 | + | ||
| 32 | 39 | const dryRun = this.npm.config.get('dry-run') | |
| 33 | 40 | const where = this.npm.prefix | |
| 34 | 41 | const opts = { | |
| 35 | 42 | ...this.npm.flatOptions, | |
| 36 | 43 | log, | |
| 37 | 44 | path: where, | |
| 38 | 45 | dryRun, | |
| 46 | + save, | ||
| 39 | 47 | workspaces: this.workspaceNames, | |
| 40 | 48 | } | |
| 41 | 49 | const arb = new Arborist(opts) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments