Skip to content

Commit dabc6dd

Browse files
MylesBorinsgengjiawen
authored andcommitted
deps: upgrade npm to 7.0.0-rc.4
PR-URL: #35576 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
1 parent d70c0ed commit dabc6dd

File tree

107 files changed

+790
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+790
-598
lines changed

deps/npm/CHANGELOG.md

Lines changed: 22 additions & 0 deletions

deps/npm/docs/public/cli-commands/npm-access/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-adduser/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-audit/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-bin/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-bugs/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-bundle/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-cache/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-ci/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-completion/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-config/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-dedupe/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-deprecate/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-dist-tag/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-docs/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-doctor/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-edit/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-exec/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-explain/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-explore/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-fund/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-help-search/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-help/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-hook/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-init/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-install-ci-test/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-install-test/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-install/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-link/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-logout/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-ls/index.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-org/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-outdated/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-owner/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-pack/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-ping/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-prefix/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-profile/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-prune/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-publish/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-rebuild/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-repo/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-restart/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-root/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-run-script/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-search/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-shrinkwrap/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-star/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-stars/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-start/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-stop/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-team/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-test/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-token/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-uninstall/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-unpublish/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-update/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-version/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-view/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm-whoami/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npm/index.html

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/cli-commands/npx/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/folders/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/install/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/npmrc/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/package-json/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/package-lock-json/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/package-locks/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/configuring-npm/shrinkwrap-json/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/config/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/developers/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/disputes/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/orgs/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/registry/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/removal/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/scope/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/scripts/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/docs/public/using-npm/semver/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

deps/npm/lib/completion.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const shorthandNames = Object.keys(shorthands)
4343
const allConfs = configNames.concat(shorthandNames)
4444
const isWindowsShell = require('./utils/is-windows-shell.js')
4545
const output = require('./utils/output.js')
46+
const fileExists = require('./utils/file-exists.js')
4647

4748
const usageUtil = require('./utils/usage.js')
4849
const usage = usageUtil('completion', 'source <(npm completion)')
@@ -56,13 +57,10 @@ const completion = async (opts, cb) => {
5657
return cb()
5758
}
5859

59-
const fs = require('fs')
60-
const stat = promisify(fs.stat)
61-
const exists = f => stat(f).then(() => true).catch(() => false)
6260
const { resolve } = require('path')
6361
const [bashExists, zshExists] = await Promise.all([
64-
exists(resolve(process.env.HOME, '.bashrc')),
65-
exists(resolve(process.env.HOME, '.zshrc'))
62+
fileExists(resolve(process.env.HOME, '.bashrc')),
63+
fileExists(resolve(process.env.HOME, '.zshrc'))
6664
])
6765
const out = []
6866
if (zshExists) {

deps/npm/lib/exec.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ const crypto = require('crypto')
5959
const pacote = require('pacote')
6060
const npa = require('npm-package-arg')
6161
const escapeArg = require('./utils/escape-arg.js')
62+
const fileExists = require('./utils/file-exists.js')
63+
const PATH = require('./utils/path.js')
6264

6365
const cmd = (args, cb) => exec(args).then(() => cb()).catch(cb)
6466

@@ -69,8 +71,38 @@ const exec = async args => {
6971
throw usage
7072
}
7173

74+
const pathArr = [...PATH]
75+
7276
const needPackageCommandSwap = args.length && !packages.length
77+
// if there's an argument and no package has been explicitly asked for
78+
// check the local and global bin paths for a binary named the same as
79+
// the argument and run it if it exists, otherwise fall through to
80+
// the behavior of treating the single argument as a package name
7381
if (needPackageCommandSwap) {
82+
let binExists = false
83+
if (await fileExists(`${npm.localBin}/${args[0]}`)) {
84+
pathArr.unshift(npm.localBin)
85+
binExists = true
86+
} else if (await fileExists(`${npm.globalBin}/${args[0]}`)) {
87+
pathArr.unshift(npm.globalBin)
88+
binExists = true
89+
}
90+
91+
if (binExists) {
92+
return await runScript({
93+
cmd: [args[0], ...args.slice(1).map(escapeArg)].join(' ').trim(),
94+
banner: false,
95+
// we always run in cwd, not --prefix
96+
path: process.cwd(),
97+
stdioString: true,
98+
event: 'npx',
99+
env: {
100+
PATH: pathArr.join(delimiter)
101+
},
102+
stdio: 'inherit'
103+
})
104+
}
105+
74106
packages.push(args[0])
75107
}
76108

@@ -111,7 +143,6 @@ const exec = async args => {
111143
// do we have all the packages in manifest list?
112144
const needInstall = manis.some(mani => manifestMissing(tree, mani))
113145

114-
const pathArr = [process.env.PATH]
115146
if (needInstall) {
116147
const installDir = cacheInstallDir(packages)
117148
await mkdirp(installDir)
@@ -126,19 +157,25 @@ const exec = async args => {
126157

127158
// no need to install if already present
128159
if (add.length) {
160+
const isTTY = process.stdin.isTTY && process.stdout.isTTY
129161
if (!npm.flatOptions.yes) {
130162
// set -n to always say no
131163
if (npm.flatOptions.yes === false) {
132164
throw 'canceled'
133165
}
134-
const addList = add.map(a => ` ${a.replace(/@$/, '')}`)
135-
.join('\n') + '\n'
136-
const prompt = `Need to install the following packages:\n${
137-
addList
138-
}Ok to proceed? `
139-
const confirm = await read({ prompt, default: 'y' })
140-
if (confirm.trim().toLowerCase().charAt(0) !== 'y') {
141-
throw 'canceled'
166+
167+
if (!isTTY) {
168+
npm.log.warn('exec', `The following package${add.length === 1 ? ' was' : 's were'} not found and will be installed: ${add.map((pkg) => pkg.replace(/@$/, '')).join(', ')}`)
169+
} else {
170+
const addList = add.map(a => ` ${a.replace(/@$/, '')}`)
171+
.join('\n') + '\n'
172+
const prompt = `Need to install the following packages:\n${
173+
addList
174+
}Ok to proceed? `
175+
const confirm = await read({ prompt, default: 'y' })
176+
if (confirm.trim().toLowerCase().charAt(0) !== 'y') {
177+
throw 'canceled'
178+
}
142179
}
143180
}
144181
await arb.reify({ ...npm.flatOptions, add })

deps/npm/lib/npm.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ const npm = module.exports = new class extends EventEmitter {
164164
await this.config.load()
165165
this.argv = this.config.parsedArgv.remain
166166

167-
setUserAgent(this.config)
168-
169167
this.color = setupLog(this.config, this)
170168
process.env.COLOR = this.color ? '1' : '0'
171169

@@ -279,7 +277,6 @@ const startMetrics = require('./utils/metrics.js').start
279277

280278
const which = promisify(require('which'))
281279

282-
const setUserAgent = require('./utils/set-user-agent.js')
283280
const deref = require('./utils/deref-command.js')
284281
const setupLog = require('./utils/setup-log.js')
285282
const cleanUpLogFiles = require('./utils/cleanup-log-files.js')

0 commit comments

Comments
 (0)