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:
authorisaacs <i@izs.me>2020-07-23 23:28:00 +0300
committerisaacs <i@izs.me>2020-07-29 21:54:59 +0300
commit8654c05e6e8cabf4642425b9e6373aeae9801c21 (patch)
treea8a5053204d15c5eff467a90175526eba6233999 /lib
parentc3b3b79b03583887ba8e63201c1a01e8043a89e9 (diff)
lint the lib folder
Diffstat (limited to 'lib')
-rw-r--r--lib/access.js2
-rw-r--r--lib/audit.js2
-rw-r--r--lib/auth/legacy.js2
-rw-r--r--lib/auth/sso.js6
-rw-r--r--lib/birthday.js23
-rw-r--r--lib/bugs.js4
-rw-r--r--lib/cache.js1
-rw-r--r--lib/config/cmd-list.js86
-rw-r--r--lib/config/core.js24
-rw-r--r--lib/config/defaults.js336
-rw-r--r--lib/config/flat-options.js2
-rw-r--r--lib/config/load-prefix.js6
-rw-r--r--lib/config/nerf-dart.js19
-rw-r--r--lib/config/set-envs.js7
-rw-r--r--lib/deprecate.js2
-rw-r--r--lib/doctor/get-latest-npm-version.js1
-rw-r--r--lib/explore.js4
-rw-r--r--lib/find-dupes.js2
-rw-r--r--lib/fund.js6
-rw-r--r--lib/help.js3
-rw-r--r--lib/hook.js8
-rw-r--r--lib/install.js3
-rw-r--r--lib/link.js8
-rw-r--r--lib/ls.js4
-rw-r--r--lib/npm.js33
-rw-r--r--lib/org.js4
-rw-r--r--lib/outdated.js20
-rw-r--r--lib/owner.js4
-rw-r--r--lib/pack.js5
-rw-r--r--lib/profile.js35
-rw-r--r--lib/publish.js8
-rw-r--r--lib/rebuild.js12
-rw-r--r--lib/repo.js4
-rw-r--r--lib/run-script.js6
-rw-r--r--lib/search.js1
-rw-r--r--lib/search/format-package-stream.js3
-rw-r--r--lib/search/package-filter.js2
-rw-r--r--lib/star.js2
-rw-r--r--lib/stars.js2
-rw-r--r--lib/team.js6
-rw-r--r--lib/token.js2
-rw-r--r--lib/uninstall.js6
-rw-r--r--lib/unpublish.js41
-rw-r--r--lib/update.js2
-rw-r--r--lib/utils/cleanup-log-files.js1
-rw-r--r--lib/utils/error-handler.js9
-rw-r--r--lib/utils/error-message.js16
-rw-r--r--lib/utils/git.js2
-rw-r--r--lib/utils/hosted-git-info-from-manifest.js6
-rw-r--r--lib/utils/open-url.js2
-rw-r--r--lib/utils/otplease.js2
-rw-r--r--lib/utils/pick-manifest-from-registry-metadata.js6
-rw-r--r--lib/utils/proc-log-listener.js2
-rw-r--r--lib/utils/pulse-till-done.js4
-rw-r--r--lib/utils/read-user-info.js8
-rw-r--r--lib/utils/reify-output.js16
-rw-r--r--lib/utils/setup-log.js5
-rw-r--r--lib/utils/update-notifier.js6
-rw-r--r--lib/view.js16
-rw-r--r--lib/xmas.js12
60 files changed, 436 insertions, 436 deletions
diff --git a/lib/access.js b/lib/access.js
index 942bc87c1..33d296f8f 100644
--- a/lib/access.js
+++ b/lib/access.js
@@ -162,7 +162,7 @@ access['ls-collaborators'] = access.lsCollaborators = async ([pkg, usr], opts) =
output(JSON.stringify(collabs, null, 2))
}
-access['edit'] = () =>
+access.edit = () =>
Promise.reject(new Error('edit subcommand is not implemented yet'))
const modifyPackage = (pkg, opts, fn, requireScope = true) =>
diff --git a/lib/audit.js b/lib/audit.js
index ffd2ec853..b14d58a5f 100644
--- a/lib/audit.js
+++ b/lib/audit.js
@@ -11,7 +11,7 @@ const audit = async args => {
path: npm.prefix
})
const fix = args[0] === 'fix'
- const result = await arb.audit({ fix })
+ await arb.audit({ fix })
if (fix) {
reifyOutput(arb)
} else {
diff --git a/lib/auth/legacy.js b/lib/auth/legacy.js
index 4258e91da..ebf526e48 100644
--- a/lib/auth/legacy.js
+++ b/lib/auth/legacy.js
@@ -52,7 +52,7 @@ function login (opts) {
).then(otp => {
const u = opts.creds.username
const p = opts.creds.password
- return profile.loginCouch(u, p, opts.concat({otp}))
+ return profile.loginCouch(u, p, opts.concat({ otp }))
})
}).then((result) => {
const newCreds = {}
diff --git a/lib/auth/sso.js b/lib/auth/sso.js
index 162a233ca..82e11fe94 100644
--- a/lib/auth/sso.js
+++ b/lib/auth/sso.js
@@ -35,7 +35,7 @@ module.exports.login = function login (creds, registry, scope, cb) {
otplease(opts,
opts => profile.loginCouch(auth.username, auth.password, opts)
- ).then(({token, sso}) => {
+ ).then(({ token, sso }) => {
if (!token) { throw new Error('no SSO token returned') }
if (!sso) { throw new Error('no SSO URL returned by services') }
return openUrl(sso, 'to complete your login please visit').then(() => {
@@ -44,7 +44,7 @@ module.exports.login = function login (creds, registry, scope, cb) {
log.info('adduser', 'Authorized user %s', username)
var scopeMessage = scope ? ' to scope ' + scope : ''
output('Logged in as %s%s on %s.', username, scopeMessage, registry)
- return {token}
+ return { token }
})
}).then(res => cb(null, res), cb)
}
@@ -54,7 +54,7 @@ function pollForSession (registry, token, opts) {
return npmFetch.json(
'/-/whoami', { ...opts, registry, forceAuth: { token } }
).then(
- ({username}) => username,
+ ({ username }) => username,
err => {
if (err.code === 'E401') {
return sleep(opts.ssoPollFrequency).then(() => {
diff --git a/lib/birthday.js b/lib/birthday.js
index f341a644c..4fc6df524 100644
--- a/lib/birthday.js
+++ b/lib/birthday.js
@@ -1,14 +1,17 @@
-// happy birthday! šŸŽ‚
+// happy birthday! šŸŽ‚
module.exports = (_, c) => {
- const B=global[Buffer.from([66,117,102,102,101,114])],
- f=B.from([102,114,111,109]),
- d=global[B[f]([68,97,116,101])],s = 8,t = 29,n = new d(),
- _6=B[f]([98,97,115,101,54,52])+'',
- l=B[f]('dG9TdHJpbmc=',_6),
- v=s=>B[f](s,_6)[l]() ,y = v('Z2V0RnVsbFllYXI='),
- a=v('Z2V0VVRDRGF0ZQ=='), m=v('Z2V0VVRDTW9udGg=') ,p=v('UGxlYXNlIHRyeSBhZ2FpbiBpbiA='),
- z = require(v('emxpYg==')), i=z[v('aW5mbGF0ZVN5bmM=')]
+ const B = global[Buffer.from([66, 117, 102, 102, 101, 114])]
+ const f = B.from([102, 114, 111, 109])
+ const D = global[B[f]([68, 97, 116, 101])]
+ const s = 8
+ const t = 29
+ const n = new D()
+ const _6 = B[f]([98, 97, 115, 101, 54, 52]) + ''
+ const l = B[f]('dG9TdHJpbmc=', _6)
+ const v = s => B[f](s, _6)[l](); const y = v('Z2V0RnVsbFllYXI=')
+ const a = v('Z2V0VVRDRGF0ZQ=='); const m = v('Z2V0VVRDTW9udGg='); const p = v('UGxlYXNlIHRyeSBhZ2FpbiBpbiA=')
+ const z = require(v('emxpYg==')); const i = z[v('aW5mbGF0ZVN5bmM=')]
- c(...(`${n[a]()}${n[m]()}` !== `${t}${s}` ? [`${p}${new d(`${n[y]()}-0${s+1}-${t}`)-n}ms`] : [null,console.log(i(B[f](B[f](JSON.parse(i(B[f]('eJw1U9Gx5DAIa4gPExsDtby5/ts4SXhnspNNAkIS8p8vtzzm32e+rp2t2007ae7HTuEWdq/VtvysHM/4rbTEdfEvLNhclqgL/Nv67AvVR+AAQHF9lguTllXrRtAmIvs9ZnJYpXXxdQ1QtzX6VnOA4JxMMBvwhZlF6DiaCL63+So3yykhCeMCDF6kCmheLaWUmHrtn5Opu4SCLYh0ilQIPvewupKylsXSJOclnZy55gm1V3bcK3RYSgd7GOCh5TvUQ2IB67Kdk0gHBsV5ek5LcchwF+WWathBoo9VUE7A6WJFfsMBX5wzD6VQGqm7HCPNkRxbJPZ82cSuaapZDKGG5ttJpXC18SBYTDPogtV94ViisUZpa+dXTrCJm/GrDtfO6uXAtdp8T+IZ/ksPJmI8bSgljH4LTV6QK6P6kkniJezk65dPeRzy9Gjh3zTeliZ0sYJJjZ9c0mCaWMrglj7IsHwGaUNaxGYuBPbNOViz6blxpk7E+QURA+n54qI1a5Ydv1QrUkeBocNFpKe8Z5ld71y29gAG78xg5zSS5/VMsat4ODL7a1BllY4OTKLhd+IruSB7/d9/b7zQBA==', _6))[l]()))[l](), _6))[l]())]))
+ c(...(`${n[a]()}${n[m]()}` !== `${t}${s}` ? [`${p}${new D(`${n[y]()}-0${s + 1}-${t}`) - n}ms`] : [null, console.log(i(B[f](B[f](JSON.parse(i(B[f]('eJw1U9Gx5DAIa4gPExsDtby5/ts4SXhnspNNAkIS8p8vtzzm32e+rp2t2007ae7HTuEWdq/VtvysHM/4rbTEdfEvLNhclqgL/Nv67AvVR+AAQHF9lguTllXrRtAmIvs9ZnJYpXXxdQ1QtzX6VnOA4JxMMBvwhZlF6DiaCL63+So3yykhCeMCDF6kCmheLaWUmHrtn5Opu4SCLYh0ilQIPvewupKylsXSJOclnZy55gm1V3bcK3RYSgd7GOCh5TvUQ2IB67Kdk0gHBsV5ek5LcchwF+WWathBoo9VUE7A6WJFfsMBX5wzD6VQGqm7HCPNkRxbJPZ82cSuaapZDKGG5ttJpXC18SBYTDPogtV94ViisUZpa+dXTrCJm/GrDtfO6uXAtdp8T+IZ/ksPJmI8bSgljH4LTV6QK6P6kkniJezk65dPeRzy9Gjh3zTeliZ0sYJJjZ9c0mCaWMrglj7IsHwGaUNaxGYuBPbNOViz6blxpk7E+QURA+n54qI1a5Ydv1QrUkeBocNFpKe8Z5ld71y29gAG78xg5zSS5/VMsat4ODL7a1BllY4OTKLhd+IruSB7/d9/b7zQBA==', _6))[l]()))[l](), _6))[l]())]))
}
diff --git a/lib/bugs.js b/lib/bugs.js
index 85b975758..e6940f36b 100644
--- a/lib/bugs.js
+++ b/lib/bugs.js
@@ -35,12 +35,12 @@ const getBugsUrl = mani => {
}
// just send them to the website, hopefully that has some info!
- return `https://www.npmjs.com/package/${mani.name}`
+ return `https://www.npmjs.com/package/${mani.name}`
}
const getBugs = async pkg => {
const opts = { ...npm.flatOptions, fullMetadata: true }
- const mani = await pacote.manifest(pkg, { fullMetadata: true })
+ const mani = await pacote.manifest(pkg, opts)
const url = getBugsUrl(mani)
log.silly('bugs', 'url', url)
await openUrl(url, `${mani.name} bug list available at the following URL`)
diff --git a/lib/cache.js b/lib/cache.js
index 62702fd83..b5417ba81 100644
--- a/lib/cache.js
+++ b/lib/cache.js
@@ -5,7 +5,6 @@ const assert = require('assert')
const cacache = require('cacache')
const { promisify } = require('util')
const log = require('npmlog')
-const npa = require('npm-package-arg')
const npm = require('./npm.js')
const output = require('./utils/output.js')
const pacote = require('pacote')
diff --git a/lib/config/cmd-list.js b/lib/config/cmd-list.js
index 8e6c03855..0775b8131 100644
--- a/lib/config/cmd-list.js
+++ b/lib/config/cmd-list.js
@@ -1,56 +1,56 @@
// short names for common things
const shorthands = {
- 'un': 'uninstall',
- 'rb': 'rebuild',
- 'list': 'ls',
- 'ln': 'link',
- 'create': 'init',
- 'i': 'install',
- 'it': 'install-test',
- 'cit': 'install-ci-test',
- 'up': 'update',
- 'c': 'config',
- 's': 'search',
- 'se': 'search',
- 'unstar': 'star', // same function
- 'tst': 'test',
- 't': 'test',
- 'ddp': 'dedupe',
- 'v': 'view',
- 'run': 'run-script',
+ un: 'uninstall',
+ rb: 'rebuild',
+ list: 'ls',
+ ln: 'link',
+ create: 'init',
+ i: 'install',
+ it: 'install-test',
+ cit: 'install-ci-test',
+ up: 'update',
+ c: 'config',
+ s: 'search',
+ se: 'search',
+ unstar: 'star', // same function
+ tst: 'test',
+ t: 'test',
+ ddp: 'dedupe',
+ v: 'view',
+ run: 'run-script',
'clean-install': 'ci',
'clean-install-test': 'cit'
}
const affordances = {
- 'la': 'll',
- 'verison': 'version',
- 'ic': 'ci',
- 'innit': 'init',
- 'isntall': 'install',
+ la: 'll',
+ verison: 'version',
+ ic: 'ci',
+ innit: 'init',
+ isntall: 'install',
'install-clean': 'ci',
'isntall-clean': 'ci',
'dist-tags': 'dist-tag',
- 'apihelp': 'help',
- 'upgrade': 'update',
- 'udpate': 'update',
- 'login': 'adduser',
+ apihelp: 'help',
+ upgrade: 'update',
+ udpate: 'update',
+ login: 'adduser',
'add-user': 'adduser',
- 'author': 'owner',
- 'home': 'docs',
- 'issues': 'bugs',
- 'info': 'view',
- 'show': 'view',
- 'find': 'search',
- 'add': 'install',
- 'unlink': 'uninstall',
- 'remove': 'uninstall',
- 'rm': 'uninstall',
- 'r': 'uninstall',
- 'rum': 'run-script',
- 'sit': 'cit',
- 'urn': 'run-script',
- 'ogr': 'org'
+ author: 'owner',
+ home: 'docs',
+ issues: 'bugs',
+ info: 'view',
+ show: 'view',
+ find: 'search',
+ add: 'install',
+ unlink: 'uninstall',
+ remove: 'uninstall',
+ rm: 'uninstall',
+ r: 'uninstall',
+ rum: 'run-script',
+ sit: 'cit',
+ urn: 'run-script',
+ ogr: 'org'
}
// these are filenames in .
@@ -122,7 +122,7 @@ const cmdList = [
'doctor'
]
-const plumbing = [ 'birthday' ]
+const plumbing = ['birthday']
module.exports = {
aliases: Object.assign({}, shorthands, affordances),
shorthands,
diff --git a/lib/config/core.js b/lib/config/core.js
index 78725aeda..13dabc4a1 100644
--- a/lib/config/core.js
+++ b/lib/config/core.js
@@ -2,7 +2,6 @@ const CC = require('config-chain').ConfigChain
const inherits = require('inherits')
const configDefs = require('./defaults.js')
const types = configDefs.types
-const once = require('once')
const fs = require('fs')
const path = require('path')
const nopt = require('nopt')
@@ -12,12 +11,9 @@ const mkdirp = require('mkdirp-infer-owner')
const umask = require('../utils/umask')
const isWindows = require('../utils/is-windows.js')
-
const myUid = process.getuid && process.getuid()
const myGid = process.getgid && process.getgid()
-const loadCbs = []
-
const { promisify } = require('util')
const load = async (cli, builtin) => {
// clone the cli object that's passed in, so we don't mutate it
@@ -365,14 +361,18 @@ exports.rootConf = null
exports.usingBuiltin = false
exports.defs = configDefs
-Object.defineProperty(exports, 'defaults', { get: function () {
- return configDefs.defaults
-},
-enumerable: true })
+Object.defineProperty(exports, 'defaults', {
+ get: function () {
+ return configDefs.defaults
+ },
+ enumerable: true
+})
-Object.defineProperty(exports, 'types', { get: function () {
- return configDefs.types
-},
-enumerable: true })
+Object.defineProperty(exports, 'types', {
+ get: function () {
+ return configDefs.types
+ },
+ enumerable: true
+})
exports.validate = validate
diff --git a/lib/config/defaults.js b/lib/config/defaults.js
index 2ce85b5df..93c6b2cb1 100644
--- a/lib/config/defaults.js
+++ b/lib/config/defaults.js
@@ -15,9 +15,11 @@ try {
log = require('npmlog')
} catch (er) {
var util = require('util')
- log = { warn: function (m) {
- console.warn(m + ' ' + util.format.apply(util, [].slice.call(arguments, 1)))
- } }
+ log = {
+ warn: function (m) {
+ console.warn(m + ' ' + util.format.apply(util, [].slice.call(arguments, 1)))
+ }
+ }
}
exports.Umask = Umask
@@ -82,179 +84,181 @@ var cacheRoot = (process.platform === 'win32' && process.env.APPDATA) || home
var cache = path.resolve(cacheRoot, cacheExtra)
var globalPrefix
-Object.defineProperty(exports, 'defaults', {get: function () {
- if (defaults) return defaults
+Object.defineProperty(exports, 'defaults', {
+ get: function () {
+ if (defaults) return defaults
- if (process.env.PREFIX) {
- globalPrefix = process.env.PREFIX
- } else if (process.platform === 'win32') {
+ if (process.env.PREFIX) {
+ globalPrefix = process.env.PREFIX
+ } else if (process.platform === 'win32') {
// c:\node\node.exe --> prefix=c:\node\
- globalPrefix = path.dirname(process.execPath)
- } else {
+ globalPrefix = path.dirname(process.execPath)
+ } else {
// /usr/local/bin/node --> prefix=/usr/local
- globalPrefix = path.dirname(path.dirname(process.execPath))
+ globalPrefix = path.dirname(path.dirname(process.execPath))
- // destdir only is respected on Unix
- if (process.env.DESTDIR) {
- globalPrefix = path.join(process.env.DESTDIR, globalPrefix)
+ // destdir only is respected on Unix
+ if (process.env.DESTDIR) {
+ globalPrefix = path.join(process.env.DESTDIR, globalPrefix)
+ }
}
- }
- defaults = {
- access: null,
- all: false,
- 'allow-same-version': false,
- 'always-auth': false,
- also: null,
- audit: true,
- 'audit-level': null,
- 'auth-type': 'legacy',
-
- 'before': null,
- 'bin-links': true,
- browser: null,
-
- ca: null,
- cafile: null,
-
- cache: cache,
-
- 'cache-lock-stale': 60000,
- 'cache-lock-retries': 10,
- 'cache-lock-wait': 10000,
-
- 'cache-max': Infinity,
- 'cache-min': 10,
-
- cert: null,
-
- cidr: null,
-
- color: process.env.NO_COLOR == null,
- depth: 0,
- description: true,
- dev: false,
- 'dry-run': false,
- editor: osenv.editor(),
- 'engine-strict': false,
- force: false,
- 'format-package-lock': true,
-
- fund: true,
-
- 'fetch-retries': 2,
- 'fetch-retry-factor': 10,
- 'fetch-retry-mintimeout': 10000,
- 'fetch-retry-maxtimeout': 60000,
-
- git: 'git',
- 'git-tag-version': true,
- 'commit-hooks': true,
-
- global: false,
- globalconfig: path.resolve(globalPrefix, 'etc', 'npmrc'),
- 'global-style': false,
- group: process.platform === 'win32' ? 0
- : process.env.SUDO_GID || (process.getgid && process.getgid()),
- 'ham-it-up': false,
- heading: 'npm',
- 'if-present': false,
- include: [],
- 'include-staged': false,
- 'ignore-prepublish': false,
- 'ignore-scripts': false,
- 'init-module': path.resolve(home, '.npm-init.js'),
- 'init-author-name': '',
- 'init-author-email': '',
- 'init-author-url': '',
- 'init-version': '1.0.0',
- 'init-license': 'ISC',
- json: false,
- key: null,
- 'legacy-bundling': false,
- 'legacy-peer-deps': false,
- link: false,
- 'local-address': undefined,
- loglevel: 'notice',
- 'logs-max': 10,
- long: false,
- maxsockets: 50,
- message: '%s',
- 'metrics-registry': null,
- 'node-options': null,
- 'node-version': process.version,
- 'offline': false,
- omit: [],
- only: null,
- optional: true,
- otp: null,
- 'package-lock': true,
- 'package-lock-only': false,
- parseable: false,
- 'prefer-offline': false,
- 'prefer-online': false,
- prefix: globalPrefix,
- preid: '',
- production: process.env.NODE_ENV === 'production',
- 'progress': !process.env.TRAVIS && !process.env.CI,
- proxy: null,
- 'https-proxy': null,
- 'noproxy': null,
- 'user-agent': 'npm/{npm-version} ' +
+ defaults = {
+ access: null,
+ all: false,
+ 'allow-same-version': false,
+ 'always-auth': false,
+ also: null,
+ audit: true,
+ 'audit-level': null,
+ 'auth-type': 'legacy',
+
+ before: null,
+ 'bin-links': true,
+ browser: null,
+
+ ca: null,
+ cafile: null,
+
+ cache: cache,
+
+ 'cache-lock-stale': 60000,
+ 'cache-lock-retries': 10,
+ 'cache-lock-wait': 10000,
+
+ 'cache-max': Infinity,
+ 'cache-min': 10,
+
+ cert: null,
+
+ cidr: null,
+
+ color: process.env.NO_COLOR == null,
+ depth: 0,
+ description: true,
+ dev: false,
+ 'dry-run': false,
+ editor: osenv.editor(),
+ 'engine-strict': false,
+ force: false,
+ 'format-package-lock': true,
+
+ fund: true,
+
+ 'fetch-retries': 2,
+ 'fetch-retry-factor': 10,
+ 'fetch-retry-mintimeout': 10000,
+ 'fetch-retry-maxtimeout': 60000,
+
+ git: 'git',
+ 'git-tag-version': true,
+ 'commit-hooks': true,
+
+ global: false,
+ globalconfig: path.resolve(globalPrefix, 'etc', 'npmrc'),
+ 'global-style': false,
+ group: process.platform === 'win32' ? 0
+ : process.env.SUDO_GID || (process.getgid && process.getgid()),
+ 'ham-it-up': false,
+ heading: 'npm',
+ 'if-present': false,
+ include: [],
+ 'include-staged': false,
+ 'ignore-prepublish': false,
+ 'ignore-scripts': false,
+ 'init-module': path.resolve(home, '.npm-init.js'),
+ 'init-author-name': '',
+ 'init-author-email': '',
+ 'init-author-url': '',
+ 'init-version': '1.0.0',
+ 'init-license': 'ISC',
+ json: false,
+ key: null,
+ 'legacy-bundling': false,
+ 'legacy-peer-deps': false,
+ link: false,
+ 'local-address': undefined,
+ loglevel: 'notice',
+ 'logs-max': 10,
+ long: false,
+ maxsockets: 50,
+ message: '%s',
+ 'metrics-registry': null,
+ 'node-options': null,
+ 'node-version': process.version,
+ offline: false,
+ omit: [],
+ only: null,
+ optional: true,
+ otp: null,
+ 'package-lock': true,
+ 'package-lock-only': false,
+ parseable: false,
+ 'prefer-offline': false,
+ 'prefer-online': false,
+ prefix: globalPrefix,
+ preid: '',
+ production: process.env.NODE_ENV === 'production',
+ progress: !process.env.TRAVIS && !process.env.CI,
+ proxy: null,
+ 'https-proxy': null,
+ noproxy: null,
+ 'user-agent': 'npm/{npm-version} ' +
'node/{node-version} ' +
'{platform} ' +
'{arch} ' +
'{ci}',
- 'read-only': false,
- 'rebuild-bundle': true,
- registry: 'https://registry.npmjs.org/',
- rollback: true,
- save: true,
- 'save-bundle': false,
- 'save-dev': false,
- 'save-exact': false,
- 'save-optional': false,
- 'save-prefix': '^',
- 'save-prod': false,
- scope: '',
- 'script-shell': null,
- 'scripts-prepend-node-path': 'warn-only',
- searchopts: '',
- searchexclude: null,
- searchlimit: 20,
- searchstaleness: 15 * 60,
- 'send-metrics': false,
- shell: osenv.shell(),
- shrinkwrap: true,
- 'sign-git-commit': false,
- 'sign-git-tag': false,
- 'sso-poll-frequency': 500,
- 'sso-type': 'oauth',
- 'strict-ssl': true,
- tag: 'latest',
- 'tag-version-prefix': 'v',
- timing: false,
- tmp: temp,
- unicode: hasUnicode(),
- 'unsafe-perm': process.platform === 'win32' ||
+ 'read-only': false,
+ 'rebuild-bundle': true,
+ registry: 'https://registry.npmjs.org/',
+ rollback: true,
+ save: true,
+ 'save-bundle': false,
+ 'save-dev': false,
+ 'save-exact': false,
+ 'save-optional': false,
+ 'save-prefix': '^',
+ 'save-prod': false,
+ scope: '',
+ 'script-shell': null,
+ 'scripts-prepend-node-path': 'warn-only',
+ searchopts: '',
+ searchexclude: null,
+ searchlimit: 20,
+ searchstaleness: 15 * 60,
+ 'send-metrics': false,
+ shell: osenv.shell(),
+ shrinkwrap: true,
+ 'sign-git-commit': false,
+ 'sign-git-tag': false,
+ 'sso-poll-frequency': 500,
+ 'sso-type': 'oauth',
+ 'strict-ssl': true,
+ tag: 'latest',
+ 'tag-version-prefix': 'v',
+ timing: false,
+ tmp: temp,
+ unicode: hasUnicode(),
+ 'unsafe-perm': process.platform === 'win32' ||
process.platform === 'cygwin' ||
!(process.getuid && process.setuid &&
process.getgid && process.setgid) ||
process.getuid() !== 0,
- 'update-notifier': true,
- usage: false,
- user: (process.platform === 'win32' || os.type() === 'OS400') ? 0 : 'nobody',
- userconfig: path.resolve(home, '.npmrc'),
- umask: process.umask ? process.umask() : umask.fromString('022'),
- version: false,
- versions: false,
- viewer: process.platform === 'win32' ? 'browser' : 'man',
-
- _exit: true
- }
+ 'update-notifier': true,
+ usage: false,
+ user: (process.platform === 'win32' || os.type() === 'OS400') ? 0 : 'nobody',
+ userconfig: path.resolve(home, '.npmrc'),
+ umask: process.umask ? process.umask() : umask.fromString('022'),
+ version: false,
+ versions: false,
+ viewer: process.platform === 'win32' ? 'browser' : 'man',
+
+ _exit: true
+ }
- return defaults
-}})
+ return defaults
+ }
+})
exports.types = {
access: [null, 'restricted', 'public'],
@@ -265,7 +269,7 @@ exports.types = {
audit: Boolean,
'audit-level': ['low', 'moderate', 'high', 'critical', 'none', null],
'auth-type': ['legacy', 'sso', 'saml', 'oauth'],
- 'before': [null, Date],
+ before: [null, Date],
'bin-links': Boolean,
browser: [null, Boolean, String],
ca: [null, String, Array],
@@ -302,7 +306,7 @@ exports.types = {
'https-proxy': [null, url],
'user-agent': String,
'ham-it-up': Boolean,
- 'heading': String,
+ heading: String,
'if-present': Boolean,
include: [Array, 'dev', 'optional', 'peer'],
'include-staged': Boolean,
@@ -328,7 +332,7 @@ exports.types = {
'metrics-registry': [null, String],
'node-options': [null, String],
'node-version': [null, semver],
- 'noproxy': [null, String, Array],
+ noproxy: [null, String, Array],
offline: Boolean,
omit: [Array, 'dev', 'optional', 'peer'],
only: [null, 'dev', 'development', 'prod', 'production'],
@@ -399,7 +403,7 @@ function getLocalAddresses () {
}
return Object.keys(interfaces).map(
- nic => interfaces[nic].map(({address}) => address)
+ nic => interfaces[nic].map(({ address }) => address)
).reduce((curr, next) => curr.concat(next), []).concat(undefined)
}
@@ -425,7 +429,7 @@ exports.shorthands = {
f: ['--force'],
desc: ['--description'],
'no-desc': ['--no-description'],
- 'local': ['--no-global'],
+ local: ['--no-global'],
l: ['--long'],
m: ['--message'],
p: ['--parseable'],
diff --git a/lib/config/flat-options.js b/lib/config/flat-options.js
index 2cf928ad5..e2e0bfdd9 100644
--- a/lib/config/flat-options.js
+++ b/lib/config/flat-options.js
@@ -5,7 +5,7 @@ const log = require('npmlog')
const crypto = require('crypto')
const npmSession = crypto.randomBytes(8).toString('hex')
log.verbose('npm-session', npmSession)
-const {join} = require('path')
+const { join } = require('path')
const buildOmitList = npm => {
const include = npm.config.get('include') || []
diff --git a/lib/config/load-prefix.js b/lib/config/load-prefix.js
index 090865d21..fd80e7634 100644
--- a/lib/config/load-prefix.js
+++ b/lib/config/load-prefix.js
@@ -32,9 +32,11 @@ function loadPrefix (cb) {
var p
Object.defineProperty(this, 'localPrefix',
- { set: function (prefix) { p = prefix },
+ {
+ set: function (prefix) { p = prefix },
get: function () { return p },
- enumerable: true })
+ enumerable: true
+ })
// try to guess at a good node_modules location.
// If we are *explicitly* given a prefix on the cli, then
diff --git a/lib/config/nerf-dart.js b/lib/config/nerf-dart.js
index 8d2bdd26e..d6ae4aa2a 100644
--- a/lib/config/nerf-dart.js
+++ b/lib/config/nerf-dart.js
@@ -1,6 +1,4 @@
-var url = require('url')
-
-module.exports = toNerfDart
+const { URL } = require('url')
/**
* Maps a URL to an identifier.
@@ -11,13 +9,10 @@ module.exports = toNerfDart
*
* @returns {String} A nerfed URL.
*/
-function toNerfDart (uri) {
- var parsed = url.parse(uri)
- delete parsed.protocol
- delete parsed.auth
- delete parsed.query
- delete parsed.search
- delete parsed.hash
-
- return url.resolve(url.format(parsed), '.')
+module.exports = (url) => {
+ const parsed = new URL(url)
+ const from = `${parsed.protocol}//${parsed.host}${parsed.pathname}`
+ const rel = new URL('.', from)
+ const res = `//${rel.host}${rel.pathname}`
+ return res
}
diff --git a/lib/config/set-envs.js b/lib/config/set-envs.js
index 63c6006f5..cd719c6bc 100644
--- a/lib/config/set-envs.js
+++ b/lib/config/set-envs.js
@@ -3,13 +3,11 @@
//
// See https://github.com/npm/rfcs/pull/90
-const envName = name => `npm_config_${name.replace(/-/g, '_')}`
-
// Return the env key if this is a thing that belongs in the env.
// Ie, if the key isn't a @scope, //nerf.dart, or _private,
// and the value is a string or array. Otherwise return false.
const envKey = (key, val) => {
- return !/^[\/@_]/.test(key) &&
+ return !/^[/@_]/.test(key) &&
(typeof val === 'string' || Array.isArray(val)) &&
`npm_config_${key.replace(/-/g, '_').toLowerCase()}`
}
@@ -36,9 +34,8 @@ const setEnvs = npm => {
// The objects in the config.list array are arranged in
// a prototype chain, so we can just for/in over the top
// of the stack and grab any that don't match the default
- const { config: { list: [ configs ] } } = npm
+ const { config: { list: [configs] } } = npm
const { defaults } = require('./defaults.js')
- const set = {}
for (const key in configs) {
const val = configs[key]
const environ = envKey(key, val)
diff --git a/lib/deprecate.js b/lib/deprecate.js
index f15eb6229..d7a9a9481 100644
--- a/lib/deprecate.js
+++ b/lib/deprecate.js
@@ -51,7 +51,7 @@ function deprecate ([pkg, msg], opts, cb) {
return fetch.json(uri, {
...opts,
spec: p,
- query: {write: true}
+ query: { write: true }
}).then(packument => {
// filter all the versions that match
Object.keys(packument.versions)
diff --git a/lib/doctor/get-latest-npm-version.js b/lib/doctor/get-latest-npm-version.js
index 83b600396..be3a87cb8 100644
--- a/lib/doctor/get-latest-npm-version.js
+++ b/lib/doctor/get-latest-npm-version.js
@@ -1,6 +1,5 @@
const log = require('npmlog')
const pacote = require('pacote')
-const npm = require('../npm.js')
const getLatestNpmVersion = async cb => {
const tracker = log.newItem('getLatestNpmVersion', 1)
diff --git a/lib/explore.js b/lib/explore.js
index 0c9930f8e..acf9dc9d5 100644
--- a/lib/explore.js
+++ b/lib/explore.js
@@ -20,7 +20,7 @@ function explore (args, cb) {
var p = args.shift()
var cwd = path.resolve(npm.dir, p)
- var opts = {cwd: cwd, stdio: 'inherit'}
+ var opts = { cwd: cwd, stdio: 'inherit' }
var shellArgs = []
if (args) {
@@ -50,7 +50,7 @@ function explore (args, cb) {
)
}
- log.silly('explore', {sh, shellArgs, opts})
+ log.silly('explore', { sh, shellArgs, opts })
var shell = spawn(sh, shellArgs, opts)
shell.on('close', function (er) {
// only fail if non-interactive.
diff --git a/lib/find-dupes.js b/lib/find-dupes.js
index bb0e91ecf..957916378 100644
--- a/lib/find-dupes.js
+++ b/lib/find-dupes.js
@@ -4,6 +4,6 @@ const usageUtil = require('./utils/usage.js')
const usage = usageUtil('find-dupes', 'npm find-dupes')
const completion = require('./utils/completion/none.js')
-const cmd = (args, cb) => dedupe({ dryRun: true } , cb)
+const cmd = (args, cb) => dedupe({ dryRun: true }, cb)
module.exports = Object.assign(cmd, { usage, completion })
diff --git a/lib/fund.js b/lib/fund.js
index 660e22468..fdd1bd07a 100644
--- a/lib/fund.js
+++ b/lib/fund.js
@@ -80,8 +80,7 @@ function printHuman (fundingInfo, { unicode }) {
// puts child nodes back into returned archy
// output while also filtering out missing items
leave: (item, children) => {
- if (item)
- item.nodes = children.filter(Boolean)
+ if (item) { item.nodes = children.filter(Boolean) }
return item
},
@@ -102,7 +101,6 @@ function printHuman (fundingInfo, { unicode }) {
async function openFundingUrl ({ path, tree, spec, fundingSourceNumber }) {
const arg = npa(spec, path)
const retrievePackageMetadata = () => {
-
if (arg.type === 'directory') {
if (tree.path === arg.fetchSpec) {
// matches cwd, e.g: npm fund .
@@ -118,7 +116,7 @@ async function openFundingUrl ({ path, tree, spec, fundingSourceNumber }) {
} else {
// tries to retrieve a package from arborist inventory
// by matching resulted package name from the provided spec
- const [ item ] = [...tree.inventory.query('name', arg.name)]
+ const [item] = [...tree.inventory.query('name', arg.name)]
.filter(i => semver.valid(i.package.version))
.sort((a, b) => semver.rcompare(a.package.version, b.package.version))
diff --git a/lib/help.js b/lib/help.js
index f5e2fde88..a1fc11dab 100644
--- a/lib/help.js
+++ b/lib/help.js
@@ -14,7 +14,6 @@ var openUrl = require('./utils/open-url')
var glob = require('glob')
var didYouMean = require('./utils/did-you-mean')
var cmdList = require('./config/cmd-list').cmdList
-var shorthands = require('./config/cmd-list').shorthands
var commands = cmdList
var output = require('./utils/output.js')
@@ -58,7 +57,7 @@ function help (args, cb) {
var pref = [1, 5, 7]
if (argnum) {
- pref = [ argnum ].concat(pref.filter(function (n) {
+ pref = [argnum].concat(pref.filter(function (n) {
return n !== argnum
}))
}
diff --git a/lib/hook.js b/lib/hook.js
index 3f189dd80..d3ad85346 100644
--- a/lib/hook.js
+++ b/lib/hook.js
@@ -21,7 +21,7 @@ hook.completion = (opts, cb) => {
}
function UsageError () {
- throw Object.assign(new Error(hook.usage), {code: 'EUSAGE'})
+ throw Object.assign(new Error(hook.usage), { code: 'EUSAGE' })
}
// XXX once completely de-figged this can be changed to
@@ -84,10 +84,10 @@ function ls (pkg, opts) {
} else {
output(`You have ${hooks.length} hooks configured.`)
}
- const table = new Table({head: ['id', 'target', 'endpoint']})
+ const table = new Table({ head: ['id', 'target', 'endpoint'] })
hooks.forEach((hook) => {
table.push([
- {rowSpan: 2, content: hook.id},
+ { rowSpan: 2, content: hook.id },
hookName(hook),
hook.endpoint
])
@@ -100,7 +100,7 @@ function ls (pkg, opts) {
hook.response_code
])
} else {
- table.push([{colSpan: 2, content: 'never triggered'}])
+ table.push([{ colSpan: 2, content: 'never triggered' }])
}
})
output(table.toString())
diff --git a/lib/install.js b/lib/install.js
index dc74500ff..988b0fbfa 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -38,7 +38,7 @@ const install = async (args, cb) => {
try {
await arb.reify({
...npm.flatOptions,
- add: args,
+ add: args
})
reifyOutput(arb)
cb()
@@ -114,7 +114,6 @@ const completion = async (opts, cb) => {
// no matches
return cb(null, [])
}
-
} catch {
return cb(null, []) // invalid dir: no matching
}
diff --git a/lib/link.js b/lib/link.js
index 8480f0ca1..0a1fbc52f 100644
--- a/lib/link.js
+++ b/lib/link.js
@@ -4,7 +4,6 @@
const npm = require('./npm.js')
const usageUtil = require('./utils/usage.js')
const reifyOutput = require('./utils/reify-output.js')
-const log = require('npmlog')
const { resolve } = require('path')
const Arborist = require('@npmcli/arborist')
@@ -24,10 +23,10 @@ const cmd = (args, cb) => link(args).then(() => cb()).catch(cb)
const link = async args => {
if (npm.config.get('global')) {
- return cb(new Error(
+ throw new Error(
'link should never be --global.\n' +
'Please re-run this command with --local'
- ))
+ )
}
args = args.filter(a => resolve(a) !== npm.prefix)
@@ -37,9 +36,10 @@ const link = async args => {
const linkInstall = async args => {
// add all the args as global installs, and then add symlink installs locally
// to the packages in the global space.
+ const globalTop = resolve(npm.globalDir, '..')
const globalArb = new Arborist({
...npm.flatOptions,
- path: resolve(npm.globalDir, '..'),
+ path: globalTop,
global: true
})
diff --git a/lib/ls.js b/lib/ls.js
index 2c6171b3c..b54ab02ba 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -34,7 +34,7 @@ const usage = usageUtil(
const cmd = (args, cb) => ls(args).then(() => cb()).catch(cb)
const initTree = async ({ arb, args, json }) => {
- let tree = await arb.loadActual()
+ const tree = await arb.loadActual()
tree[_include] = args.length === 0
tree[_depth] = 0
@@ -388,7 +388,7 @@ const ls = async (args) => {
legacyPeerDeps: false,
path
})
- let tree = await initTree({
+ const tree = await initTree({
arb,
args,
global,
diff --git a/lib/npm.js b/lib/npm.js
index 635430979..506d5cb8b 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -6,12 +6,10 @@
// these are all dependencies used in the ctor
const EventEmitter = require('events')
const { resolve } = require('path')
-const parseJSON = require('json-parse-even-better-errors')
-const rimraf = require('rimraf')
-const gfs = require('graceful-fs')
// Patch the global fs module here at the app level
-const fs = gfs.gracefulify(require('fs'))
+require('graceful-fs').gracefulify(require('fs'))
+
const procLogListener = require('./utils/proc-log-listener.js')
const notYetLoadedConfig = {
@@ -24,24 +22,30 @@ const notYetLoadedConfig = {
}
}
+const hasOwnProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
+
// the first time `npm.commands.xyz` is loaded, it gets added
// to the cmds object, so we don't have to load it again.
const proxyCmds = (npm) => {
const cmds = {}
return new Proxy(cmds, {
get: (prop, cmd) => {
- if (cmds.hasOwnProperty(cmd)) {
+ if (hasOwnProperty(cmds, cmd)) {
return cmds[cmd]
}
const actual = deref(cmd)
if (!actual) {
- return cmds[cmd] = undefined
+ cmds[cmd] = undefined
+ return cmds[cmd]
}
if (cmds[actual]) {
- return cmds[cmd] = cmds[actual]
+ cmds[cmd] = cmds[actual]
+ return cmds[cmd]
}
- return cmds[cmd] = cmds[actual] = makeCmd(actual)
+ cmds[actual] = makeCmd(actual)
+ cmds[cmd] = cmds[actual]
+ return cmds[cmd]
}
})
}
@@ -211,6 +215,7 @@ const npm = module.exports = new class extends EventEmitter {
get cache () {
return this.config.get('cache')
}
+
set cache (r) {
this.config.set('cache', r)
}
@@ -218,6 +223,7 @@ const npm = module.exports = new class extends EventEmitter {
get globalPrefix () {
return this.config.globalPrefix
}
+
set globalPrefix (r) {
this.config.globalPrefix = r
}
@@ -225,6 +231,7 @@ const npm = module.exports = new class extends EventEmitter {
get localPrefix () {
return this.config.localPrefix
}
+
set localPrefix (r) {
this.config.localPrefix = r
}
@@ -234,9 +241,11 @@ const npm = module.exports = new class extends EventEmitter {
? resolve(this.globalPrefix, 'lib', 'node_modules')
: resolve(this.globalPrefix, 'node_modules')
}
+
get localDir () {
return resolve(this.prefix, 'node_modules')
}
+
get dir () {
return (this.config.get('global')) ? this.globalDir : this.localDir
}
@@ -245,9 +254,11 @@ const npm = module.exports = new class extends EventEmitter {
const b = this.globalPrefix
return process.platform !== 'win32' ? resolve(b, 'bin') : b
}
+
get localBin () {
return resolve(this.dir, '.bin')
}
+
get bin () {
return this.config.get('global') ? this.globalBin : this.localBin
}
@@ -255,6 +266,7 @@ const npm = module.exports = new class extends EventEmitter {
get prefix () {
return this.config.get('global') ? this.globalPrefix : this.localPrefix
}
+
set prefix (r) {
const k = this.config.get('global') ? 'globalPrefix' : 'localPrefix'
this[k] = r
@@ -268,14 +280,13 @@ const npm = module.exports = new class extends EventEmitter {
}
return resolve(this.config.get('tmp'), this[_tmpFolder])
}
-}
+}()
// now load everything required by the class methods
const npmconf = require('./config/core.js')
const log = require('npmlog')
-const { inspect, promisify } = require('util')
-const ciDetect = require('@npmcli/ci-detect')
+const { promisify } = require('util')
const startMetrics = require('./utils/metrics.js').start
const which = promisify(require('which'))
diff --git a/lib/org.js b/lib/org.js
index 6108af7fb..0d4463fcd 100644
--- a/lib/org.js
+++ b/lib/org.js
@@ -32,7 +32,7 @@ org.completion = function (opts, cb) {
}
function UsageError () {
- throw Object.assign(new Error(org.usage), {code: 'EUSAGE'})
+ throw Object.assign(new Error(org.usage), { code: 'EUSAGE' })
}
function org ([cmd, orgname, username, role], cb) {
@@ -132,7 +132,7 @@ function orgList (org, user, opts) {
output([user, roster[user]].join('\t'))
})
} else if (!opts.silent && opts.loglevel !== 'silent') {
- const table = new Table({head: ['user', 'role']})
+ const table = new Table({ head: ['user', 'role'] })
Object.keys(roster).sort().forEach(user => {
table.push([user, roster[user]])
})
diff --git a/lib/outdated.js b/lib/outdated.js
index a4e3e7029..f86550be9 100644
--- a/lib/outdated.js
+++ b/lib/outdated.js
@@ -62,7 +62,7 @@ async function outdated (args) {
'Wanted',
'Latest',
'Location',
- 'Depended by',
+ 'Depended by'
]
if (opts.long) outHead.push('Package Type', 'Homepage')
@@ -84,12 +84,11 @@ async function outdated (args) {
async function outdated_ (tree, deps, opts) {
const list = []
-
const edges = new Set()
- function getEdges(nodes, type) {
+ function getEdges (nodes, type) {
const getEdgesIn = (node) => {
- for (const edge of node.edgesIn)Ā {
+ for (const edge of node.edgesIn) {
edges.add(edge)
}
}
@@ -102,9 +101,9 @@ async function outdated_ (tree, deps, opts) {
if (!nodes) return getEdgesOut(tree)
for (const node of nodes) {
- type === 'edgesOut' ?
- getEdgesOut(node) :
- getEdgesIn(node)
+ type === 'edgesOut'
+ ? getEdgesOut(node)
+ : getEdgesIn(node)
}
}
@@ -135,8 +134,8 @@ async function outdated_ (tree, deps, opts) {
const type = edge.optional ? 'optionalDependencies'
: edge.peer ? 'peerDependencies'
- : edge.dev ? 'devDependencies'
- : 'dependencies'
+ : edge.dev ? 'devDependencies'
+ : 'dependencies'
// deps different from prod not currently
// on disk are not included in the output
@@ -176,7 +175,6 @@ async function outdated_ (tree, deps, opts) {
throw (err)
}
}
-
}
const p = []
@@ -270,4 +268,4 @@ function makeJSON (list, opts) {
return JSON.stringify(out, null, 2)
}
-module.exports = Object.assign(cmd, { completion, usage })
+module.exports = Object.assign(cmd, { completion, usage })
diff --git a/lib/owner.js b/lib/owner.js
index 5cce13c14..7a3b9983d 100644
--- a/lib/owner.js
+++ b/lib/owner.js
@@ -75,7 +75,7 @@ owner.completion = function (opts, cb) {
}
function UsageError () {
- throw Object.assign(new Error(owner.usage), {code: 'EUSAGE'})
+ throw Object.assign(new Error(owner.usage), { code: 'EUSAGE' })
}
function owner ([action, ...args], cb) {
@@ -102,7 +102,7 @@ function ls (pkg, opts) {
}
const spec = npa(pkg)
- return packument(spec, {...opts, fullMetadata: true}).then(
+ return packument(spec, { ...opts, fullMetadata: true }).then(
data => {
var owners = data.maintainers
if (!owners || !owners.length) {
diff --git a/lib/pack.js b/lib/pack.js
index 19d8e2d8d..36fd9a228 100644
--- a/lib/pack.js
+++ b/lib/pack.js
@@ -15,7 +15,7 @@ const writeFile = util.promisify(require('fs').writeFile)
cmd.usage = 'npm pack [[<@scope>/]<pkg>...] [--dry-run]'
module.exports = cmd
-function cmd(args, silent, cb) {
+function cmd (args, silent, cb) {
if (typeof cb !== 'function') {
cb = silent
silent = false
@@ -29,7 +29,8 @@ async function pack (args, silent) {
if (args.length === 0) args = ['.']
const opts = { ...npm.flatOptions }
- const { unicode, jsonĀ } = opts
+ const { unicode, json } = opts
+
const tarballs = await Promise.all(args.map((arg) => pack_(arg, opts)))
if (!silent && json) {
output(JSON.stringify(tarballs, null, 2))
diff --git a/lib/profile.js b/lib/profile.js
index 9517718a0..43185d617 100644
--- a/lib/profile.js
+++ b/lib/profile.js
@@ -9,11 +9,10 @@ const output = require('./utils/output.js')
const profile = require('npm-profile')
const pulseTillDone = require('./utils/pulse-till-done.js')
const qrcodeTerminal = require('qrcode-terminal')
-const queryString = require('query-string')
const qw = require('qw')
const readUserInfo = require('./utils/read-user-info.js')
const Table = require('cli-table3')
-const url = require('url')
+const { URL } = require('url')
module.exports = profileCmd
@@ -94,7 +93,7 @@ function get (args) {
Object.keys(info).filter((k) => !(k in cleaned)).forEach((k) => { cleaned[k] = info[k] || '' })
delete cleaned.tfa
delete cleaned.email_verified
- cleaned['email'] += info.email_verified ? ' (verified)' : '(unverified)'
+ cleaned.email += info.email_verified ? ' (verified)' : '(unverified)'
if (info.tfa && !info.tfa.pending) {
cleaned[tfa] = info.tfa.mode
} else {
@@ -117,7 +116,7 @@ function get (args) {
})
} else {
const table = new Table()
- Object.keys(cleaned).forEach((k) => table.push({[ansistyles.bright(k)]: cleaned[k]}))
+ Object.keys(cleaned).forEach((k) => table.push({ [ansistyles.bright(k)]: cleaned[k] }))
output(table.toString())
}
}
@@ -146,12 +145,12 @@ function set (args) {
if (prop === 'password') {
return readUserInfo.password('Current password: ').then((current) => {
return readPasswords().then((newpassword) => {
- value = {old: current, new: newpassword}
+ value = { old: current, new: newpassword }
})
})
} else if (prop === 'email') {
return readUserInfo.password('Password: ').then((current) => {
- return {password: current, email: value}
+ return { password: current, email: value }
})
}
function readPasswords () {
@@ -174,7 +173,7 @@ function set (args) {
return otplease(conf, conf => profile.set(newUser, conf))
.then((result) => {
if (conf.json) {
- output(JSON.stringify({[prop]: result[prop]}, null, 2))
+ output(JSON.stringify({ [prop]: result[prop] }, null, 2))
} else if (conf.parseable) {
output(prop + '\t' + result[prop])
} else if (result[prop] != null) {
@@ -221,7 +220,7 @@ function enable2fa (args) {
auth.basic.password, false, [], conf
).then((result) => {
if (!result.token) throw new Error('Your registry ' + conf.registry + 'does not seem to support bearer tokens. Bearer tokens are required for two-factor authentication')
- npm.config.setCredentialsByURI(conf.registry, {token: result.token})
+ npm.config.setCredentialsByURI(conf.registry, { token: result.token })
return new Promise((res, rej) => {
npm.config.save('user', er => er ? rej(er) : res())
})
@@ -237,7 +236,7 @@ function enable2fa (args) {
if (!info.tfa) return
if (info.tfa.pending) {
log.info('profile', 'Resetting two-factor authentication')
- return pulseTillDone.withPromise(profile.set({tfa: {password, mode: 'disable'}}, conf))
+ return pulseTillDone.withPromise(profile.set({ tfa: { password, mode: 'disable' } }, conf))
} else {
if (conf.auth.otp) return
return readUserInfo.otp('Enter one-time password from your authenticator app: ').then((otp) => {
@@ -256,15 +255,15 @@ function enable2fa (args) {
if (typeof challenge.tfa !== 'string' || !/^otpauth:[/][/]/.test(challenge.tfa)) {
throw new Error('Unknown error enabling two-factor authentication. Expected otpauth URL, got: ' + inspect(challenge.tfa))
}
- const otpauth = url.parse(challenge.tfa)
- const opts = queryString.parse(otpauth.query)
+ const otpauth = new URL(challenge.tfa)
+ const secret = otpauth.searchParams.get('secret')
return qrcode(challenge.tfa).then((code) => {
- output('Scan into your authenticator app:\n' + code + '\n Or enter code:', opts.secret)
+ output('Scan into your authenticator app:\n' + code + '\n Or enter code:', secret)
}).then((code) => {
return readUserInfo.otp('And an OTP code from your authenticator: ')
}).then((otp1) => {
log.info('profile', 'Finalizing two-factor authentication')
- return profile.set({tfa: [otp1]}, conf)
+ return profile.set({ tfa: [otp1] }, conf)
}).then((result) => {
output('2FA successfully enabled. Below are your recovery codes, please print these out.')
output('You will need these to recover access to your account if you lose your authentication device.')
@@ -277,12 +276,12 @@ function getAuth (conf) {
const creds = npm.config.getCredentialsByURI(conf.registry)
let auth
if (creds.token) {
- auth = {token: creds.token}
+ auth = { token: creds.token }
} else if (creds.username) {
- auth = {basic: {username: creds.username, password: creds.password}}
+ auth = { basic: { username: creds.username, password: creds.password } }
} else if (creds.auth) {
const basic = Buffer.from(creds.auth, 'base64').toString().split(':', 2)
- auth = {basic: {username: basic[0], password: basic[1]}}
+ auth = { basic: { username: basic[0], password: basic[1] } }
} else {
auth = {}
}
@@ -306,9 +305,9 @@ function disable2fa (args) {
})
}).then(() => {
log.info('profile', 'disabling tfa')
- return pulseTillDone.withPromise(profile.set({tfa: {password: password, mode: 'disable'}}, conf)).then(() => {
+ return pulseTillDone.withPromise(profile.set({ tfa: { password: password, mode: 'disable' } }, conf)).then(() => {
if (conf.json) {
- output(JSON.stringify({tfa: false}, null, 2))
+ output(JSON.stringify({ tfa: false }, null, 2))
} else if (conf.parseable) {
output('tfa\tfalse')
} else {
diff --git a/lib/publish.js b/lib/publish.js
index d76ca005b..13f40a0ba 100644
--- a/lib/publish.js
+++ b/lib/publish.js
@@ -19,15 +19,15 @@ cmd.usage = 'npm publish [<folder>] [--tag <tag>] [--access <public|restricted>]
'\n\nSets tag `latest` if no --tag specified'
module.exports = cmd
-function cmd(args, cb) {
- publish(args, cb)
+function cmd (args, cb) {
+ publish(args)
.then(() => cb())
.catch(cb)
}
-async function publish (args, cb) {
+async function publish (args) {
if (args.length === 0) args = ['.']
- if (args.length !== 1) return cb(cmd.usage)
+ if (args.length !== 1) throw cmd.usage
log.verbose('publish', args)
diff --git a/lib/rebuild.js b/lib/rebuild.js
index df1d29566..a2beecc50 100644
--- a/lib/rebuild.js
+++ b/lib/rebuild.js
@@ -37,18 +37,14 @@ const rebuild = async args => {
const getFilterFn = args => {
const specs = args.map(arg => {
const spec = npa(arg)
- if (spec.type === 'tag' && spec.rawSpec === '')
- return spec
- if (spec.type !== 'range' && spec.type !== 'version')
- throw new Error('`npm rebuild` only supports SemVer version/range specifiers')
+ if (spec.type === 'tag' && spec.rawSpec === '') { return spec }
+ if (spec.type !== 'range' && spec.type !== 'version') { throw new Error('`npm rebuild` only supports SemVer version/range specifiers') }
return spec
})
return node => specs.some(spec => {
const { version } = node.package
- if (spec.name !== node.name)
- return false
- if (spec.rawSpec === '' || spec.rawSpec === '*')
- return true
+ if (spec.name !== node.name) { return false }
+ if (spec.rawSpec === '' || spec.rawSpec === '*') { return true }
return semver.satisfies(version, spec.fetchSpec)
})
}
diff --git a/lib/repo.js b/lib/repo.js
index 7b415ee23..fb2a03ab0 100644
--- a/lib/repo.js
+++ b/lib/repo.js
@@ -26,8 +26,8 @@ const getRepo = async pkg => {
const r = mani.repository
const rurl = !r ? null
: typeof r === 'string' ? r
- : typeof r === 'object' && typeof r.url === 'string' ? r.url
- : null
+ : typeof r === 'object' && typeof r.url === 'string' ? r.url
+ : null
if (!rurl) {
throw Object.assign(new Error('no repository'), {
diff --git a/lib/run-script.js b/lib/run-script.js
index 270a91ab7..3564d1c9e 100644
--- a/lib/run-script.js
+++ b/lib/run-script.js
@@ -61,7 +61,7 @@ const runScript = async (args) => {
const { scriptShell } = npm.flatOptions
const pkg = await readJson(`${path}/package.json`)
- const { _id, scripts = {} } = pkg
+ const { scripts = {} } = pkg
if (event === 'restart' && !scripts.restart) {
scripts.restart = 'npm stop && npm start'
@@ -75,7 +75,7 @@ const runScript = async (args) => {
}
const suggestions = didYouMean(event, Object.keys(scripts))
throw new Error(`missing script: ${event}${
- suggestions ? `\n${suggestions}` : '' }`)
+ suggestions ? `\n${suggestions}` : ''}`)
}
// positional args only added to the main event, not pre/post
@@ -158,7 +158,7 @@ const list = async () => {
if (!cmds.length && runScripts.length) {
output(`Scripts available in ${name} via \`npm run-script\`:`)
} else if (runScripts.length) {
- output(`\navailable via \`npm run-script\`:`)
+ output('\navailable via `npm run-script`:')
}
for (const script of runScripts) {
output(prefix + script + indent + scripts[script])
diff --git a/lib/search.js b/lib/search.js
index 96cfa3047..92397d842 100644
--- a/lib/search.js
+++ b/lib/search.js
@@ -2,7 +2,6 @@
module.exports = exports = search
-const Minipass = require('minipass')
const Pipeline = require('minipass-pipeline')
const npm = require('./npm.js')
diff --git a/lib/search/format-package-stream.js b/lib/search/format-package-stream.js
index 0a013e3de..7a9f61613 100644
--- a/lib/search/format-package-stream.js
+++ b/lib/search/format-package-stream.js
@@ -3,7 +3,6 @@
// XXX these output classes should not live in here forever. it'd be good to
// split them out, perhaps to libnpmsearch
-const Pipeline = require('minipass-pipeline')
const Minipass = require('minipass')
const columnify = require('columnify')
@@ -29,6 +28,7 @@ class JSONOutputStream extends Minipass {
super()
this._didFirst = false
}
+
write (obj) {
if (!this._didFirst) {
super.write('[\n')
@@ -42,6 +42,7 @@ class JSONOutputStream extends Minipass {
return this.emit('error', er)
}
}
+
end () {
super.write(this._didFirst ? ']\n' : '\n]\n')
}
diff --git a/lib/search/package-filter.js b/lib/search/package-filter.js
index 892adb08c..142350eec 100644
--- a/lib/search/package-filter.js
+++ b/lib/search/package-filter.js
@@ -7,7 +7,7 @@ function filter (data, include, exclude, opts) {
}
function getWords (data, opts) {
- return [ data.name ]
+ return [data.name]
.concat((opts && opts.description) ? data.description : [])
.concat((data.maintainers || []).map(function (m) {
return '=' + m.name
diff --git a/lib/star.js b/lib/star.js
index b9beda0be..04b8285fb 100644
--- a/lib/star.js
+++ b/lib/star.js
@@ -37,7 +37,7 @@ function star (args, cb) {
fetch.json(pkg.escapedName, {
...opts,
spec: pkg,
- query: {write: true},
+ query: { write: true },
preferOnline: true
})
]).then(([username, fullData]) => {
diff --git a/lib/stars.js b/lib/stars.js
index 5ad7d13db..a496108a4 100644
--- a/lib/stars.js
+++ b/lib/stars.js
@@ -19,7 +19,7 @@ function stars ([user], cb) {
return fetch.json('/-/_view/starredByUser', {
...opts,
// Note: key has to be JSON, for CouchDB legacy reasons, hence quoted
- query: {key: `"${usr}"`}
+ query: { key: `"${usr}"` }
})
}).then(data => data.rows).then(stars => {
if (stars.length === 0) {
diff --git a/lib/team.js b/lib/team.js
index e9219e3dc..a567bdba3 100644
--- a/lib/team.js
+++ b/lib/team.js
@@ -22,7 +22,7 @@ team.usage = usage(
)
function UsageError () {
- throw Object.assign(new Error(team.usage), {code: 'EUSAGE'})
+ throw Object.assign(new Error(team.usage), { code: 'EUSAGE' })
}
team.completion = function (opts, cb) {
@@ -145,7 +145,7 @@ function teamListUsers (entity, opts) {
output(users.join('\n'))
} else if (!opts.silent && opts.loglevel !== 'silent') {
output(`\n@${entity} has ${users.length} user${users.length === 1 ? '' : 's'}:\n`)
- output(columns(users, {padding: 1}))
+ output(columns(users, { padding: 1 }))
}
})
}
@@ -159,7 +159,7 @@ function teamListTeams (entity, opts) {
output(teams.join('\n'))
} else if (!opts.silent && opts.loglevel !== 'silent') {
output(`\n@${entity} has ${teams.length} team${teams.length === 1 ? '' : 's'}:\n`)
- output(columns(teams.map(t => `@${t}`), {padding: 1}))
+ output(columns(teams.map(t => `@${t}`), { padding: 1 }))
}
})
}
diff --git a/lib/token.js b/lib/token.js
index cc10ebe10..818b1df21 100644
--- a/lib/token.js
+++ b/lib/token.js
@@ -203,7 +203,7 @@ function create (args) {
Object.keys(result).forEach((k) => output(k + '\t' + result[k]))
} else {
const table = new Table()
- Object.keys(result).forEach((k) => table.push({[ansistyles.bright(k)]: String(result[k])}))
+ Object.keys(result).forEach((k) => table.push({ [ansistyles.bright(k)]: String(result[k]) }))
output(table.toString())
}
})
diff --git a/lib/uninstall.js b/lib/uninstall.js
index c4275de49..58e2f61a8 100644
--- a/lib/uninstall.js
+++ b/lib/uninstall.js
@@ -11,7 +11,7 @@ const cmd = (args, cb) => rm(args).then(() => cb()).catch(cb)
const rm = async args => {
// the /path/to/node_modules/..
- const { dryRun, global, prefix } = npm.flatOptions
+ const { global, prefix } = npm.flatOptions
const path = global ? resolve(npm.globalDir, '..') : prefix
if (!args.length) {
@@ -28,9 +28,9 @@ const rm = async args => {
const arb = new Arborist({ ...npm.flatOptions, path })
- const tree = await arb.reify({
+ await arb.reify({
...npm.flatOptions,
- rm: args,
+ rm: args
})
reifyOutput(arb)
}
diff --git a/lib/unpublish.js b/lib/unpublish.js
index 2e52ef671..4cda7afad 100644
--- a/lib/unpublish.js
+++ b/lib/unpublish.js
@@ -10,29 +10,23 @@ const libunpub = require('libnpmpublish').unpublish
const readJson = util.promisify(require('read-package-json'))
const npm = require('./npm.js')
-const usage = require('./utils/usage.js')
+const usageUtil = require('./utils/usage.js')
const output = require('./utils/output.js')
const otplease = require('./utils/otplease.js')
const whoami = util.promisify(require('./whoami.js'))
-cmd.usage = usage('unpublish', 'npm unpublish [<@scope>/]<pkg>[@<version>]')
+const usage = usageUtil('unpublish', 'npm unpublish [<@scope>/]<pkg>[@<version>]')
-module.exports = cmd
-function cmd(args, cb) {
- unpublish(args, cb)
- .then((ret) => cb(null, ret))
- .catch((err) => err.code === 'EUSAGE' ? cb(err.message) : cb(err))
-}
+const cmd = (args, cb) => unpublish(args).then(() => cb()).catch(cb)
-cmd.completion = (args, cb) => {
- completion(args)
- .then(() => cb())
- .catch(cb)
-}
-async function completion(args) {
+const completion = (args, cb) => completionFn(args)
+ .then((res) => cb(null, res))
+ .catch(cb)
+
+const completionFn = async (args) => {
const { partialWord, conf } = args
- if (conf.argv.remain.length >= 3) return cb()
+ if (conf.argv.remain.length >= 3) return
const username = await whoami([], true)
if (!username) { return [] }
@@ -58,8 +52,8 @@ async function completion(args) {
}
}
-async function unpublish (args, cb) {
- if (args.length > 1) return cb(cmd.usage)
+async function unpublish (args) {
+ if (args.length > 1) throw usage
const spec = args.length && npa(args[0])
const opts = npm.flatOptions
@@ -70,11 +64,11 @@ async function unpublish (args, cb) {
log.silly('unpublish', 'spec', spec)
if (!spec.rawSpec && !force) {
- throw Object.assign(new Error(
+ throw (
'Refusing to delete entire project.\n' +
'Run with --force to do this.\n' +
- cmd.usage
- ), {code: 'EUSAGE'})
+ usage
+ )
}
if (!spec || path.resolve(spec.name) === npm.localPrefix) {
@@ -94,12 +88,9 @@ async function unpublish (args, cb) {
if (err && err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
throw err
} else {
- throw Object.assign(new Error(`Usage: ${unpublish.usage}`), {
- code: 'EUSAGE'
- })
+ throw `Usage: ${usage}`
}
}
-
} else {
ret = await otplease(opts, opts => libunpub(spec, opts))
}
@@ -112,3 +103,5 @@ async function unpublish (args, cb) {
return ret
}
+
+module.exports = Object.assign(cmd, { completion, usage })
diff --git a/lib/update.js b/lib/update.js
index 371a15120..16b51d418 100644
--- a/lib/update.js
+++ b/lib/update.js
@@ -14,7 +14,7 @@ cmd.usage = usage(
)
module.exports = cmd
-function cmd(args, cb) {
+function cmd (args, cb) {
update(args, cb)
.then(() => cb())
.catch(cb)
diff --git a/lib/utils/cleanup-log-files.js b/lib/utils/cleanup-log-files.js
index 053c04d3e..a2c28e2e8 100644
--- a/lib/utils/cleanup-log-files.js
+++ b/lib/utils/cleanup-log-files.js
@@ -8,6 +8,7 @@ const { resolve } = require('path')
const rimraf = require('rimraf')
const glob = require('glob')
module.exports = (cache, max, warn) => {
+ /* eslint-disable promise/param-names */
return new Promise(done => {
glob(resolve(cache, '_logs', '*-debug.log'), (er, files) => {
if (er) {
diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js
index effa150df..8f5ad6fab 100644
--- a/lib/utils/error-handler.js
+++ b/lib/utils/error-handler.js
@@ -5,7 +5,6 @@ let itWorked = false
const path = require('path')
let wroteLogFile = false
let exitCode = 0
-const chain = require('slide').chain
const errorMessage = require('./error-message.js')
const stopMetrics = require('./metrics.js').stop
@@ -146,7 +145,7 @@ const errorHandler = (er) => {
er.code = m
}
- for (const k of [ 'type', 'stack', 'statusCode', 'pkgid' ]) {
+ for (const k of ['type', 'stack', 'statusCode', 'pkgid']) {
const v = er[k]
if (v) log.verbose(k, v)
}
@@ -159,7 +158,7 @@ const errorHandler = (er) => {
log.verbose('node', process.version)
log.verbose('npm ', 'v' + npm.version)
- for (const k of [ 'code', 'syscall', 'file', 'path', 'dest', 'errno' ]) {
+ for (const k of ['code', 'syscall', 'file', 'path', 'dest', 'errno']) {
const v = er[k]
if (v) log.error(k, v)
}
@@ -198,7 +197,9 @@ const writeLogFile = () => {
m.message.trim().split(/\r?\n/)
.map(line => (pref + ' ' + line).trim())
- .forEach(line => logOutput += line + os.EOL)
+ .forEach(line => {
+ logOutput += line + os.EOL
+ })
})
cacheFile.write(getLogFile(), logOutput)
diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js
index 38cb37112..5bee87472 100644
--- a/lib/utils/error-message.js
+++ b/lib/utils/error-message.js
@@ -9,12 +9,14 @@ module.exports = (er) => {
const short = []
const detail = []
switch (er.code) {
- case 'ENOLOCK':
+ case 'ENOLOCK': {
const cmd = npm.command || ''
short.push([cmd, 'This command requires an existing lockfile.'])
detail.push([cmd, 'Try creating one first with: npm i --package-lock-only'])
detail.push([cmd, `Original error: ${er.message}`])
break
+ }
+
case 'ENOAUDIT':
short.push(['audit', er.message])
break
@@ -31,7 +33,7 @@ module.exports = (er) => {
break
case 'EACCES':
- case 'EPERM':
+ case 'EPERM': {
const isCachePath = typeof er.path === 'string' &&
npm.config.loaded && er.path.startsWith(npm.config.get('cache'))
const isCacheDest = typeof er.dest === 'string' &&
@@ -69,6 +71,7 @@ module.exports = (er) => {
].join('\n')])
}
break
+ }
case 'ENOGIT':
short.push(['', er.message])
@@ -208,11 +211,11 @@ module.exports = (er) => {
])
break
- case 'EBADPLATFORM':
+ case 'EBADPLATFORM': {
const validOs = er.os.join ? er.os.join(',') : er.os
const validArch = er.cpu.join ? er.cpu.join(',') : er.cpu
- const expected = {os: validOs, arch: validArch}
- const actual = {os: process.platform, arch: process.arch}
+ const expected = { os: validOs, arch: validArch }
+ const actual = { os: process.platform, arch: process.arch }
short.push([
'notsup',
[
@@ -229,6 +232,7 @@ module.exports = (er) => {
].join('\n')
])
break
+ }
case 'EEXIST':
short.push(['', er.message])
@@ -354,5 +358,5 @@ module.exports = (er) => {
}
break
}
- return {summary: short, detail: detail}
+ return { summary: short, detail: detail }
}
diff --git a/lib/utils/git.js b/lib/utils/git.js
index 1e09f3181..369f15890 100644
--- a/lib/utils/git.js
+++ b/lib/utils/git.js
@@ -5,7 +5,6 @@ const spawn = require('./spawn')
const npm = require('../npm.js')
const which = require('which')
const git = npm.config.get('git')
-const assert = require('assert')
const log = require('npmlog')
const noProgressTillDone = require('./no-progress-while-running.js').tillDone
const { promisify } = require('util')
@@ -46,7 +45,6 @@ function chainableExec () {
}
function whichAndExec (args, options, cb) {
- assert.equal(typeof cb, 'function', 'no callback provided')
// check for git
which(git, function (err) {
if (err) {
diff --git a/lib/utils/hosted-git-info-from-manifest.js b/lib/utils/hosted-git-info-from-manifest.js
index ecb7555b1..583e722bf 100644
--- a/lib/utils/hosted-git-info-from-manifest.js
+++ b/lib/utils/hosted-git-info-from-manifest.js
@@ -6,9 +6,9 @@ module.exports = mani => {
const r = mani.repository
const rurl = !r ? null
: typeof r === 'string' ? r
- : typeof r === 'object' && typeof r.url === 'string' ? r.url
- : null
+ : typeof r === 'object' && typeof r.url === 'string' ? r.url
+ : null
// hgi returns undefined sometimes, but let's always return null here
- return rurl && hostedGitInfo.fromUrl(rurl.replace(/^git\+/, '')) || null
+ return (rurl && hostedGitInfo.fromUrl(rurl.replace(/^git\+/, ''))) || null
}
diff --git a/lib/utils/open-url.js b/lib/utils/open-url.js
index 1e826669c..8f270221c 100644
--- a/lib/utils/open-url.js
+++ b/lib/utils/open-url.js
@@ -3,7 +3,7 @@ const npm = require('../npm.js')
const output = require('./output.js')
const opener = require('opener')
-const {URL} = require('url')
+const { URL } = require('url')
const isUrlValid = url => {
try {
diff --git a/lib/utils/otplease.js b/lib/utils/otplease.js
index d8e1540bb..6a389a091 100644
--- a/lib/utils/otplease.js
+++ b/lib/utils/otplease.js
@@ -4,7 +4,7 @@ const prompt = 'This operation requires a one-time password.\nEnter OTP:'
const readUserInfo = require('./read-user-info.js')
const isOtpError = err =>
- err.code === 'EOTP' || err.code === 'E401' && /one-time pass/.test(err.body)
+ err.code === 'EOTP' || (err.code === 'E401' && /one-time pass/.test(err.body))
module.exports = otplease
function otplease (opts, fn) {
diff --git a/lib/utils/pick-manifest-from-registry-metadata.js b/lib/utils/pick-manifest-from-registry-metadata.js
index 589cef207..4161fafcc 100644
--- a/lib/utils/pick-manifest-from-registry-metadata.js
+++ b/lib/utils/pick-manifest-from-registry-metadata.js
@@ -12,14 +12,14 @@ function pickManifestFromRegistryMetadata (spec, tag, versions, metadata) {
if (tagged &&
metadata.versions[tagged] &&
semver.satisfies(tagged, spec, true)) {
- return {resolvedTo: tag, manifest: metadata.versions[tagged]}
+ return { resolvedTo: tag, manifest: metadata.versions[tagged] }
}
// find the max satisfying version.
var ms = semver.maxSatisfying(versions, spec, true)
if (ms) {
- return {resolvedTo: ms, manifest: metadata.versions[ms]}
+ return { resolvedTo: ms, manifest: metadata.versions[ms] }
} else if (spec === '*' && versions.length && tagged && metadata.versions[tagged]) {
- return {resolvedTo: tag, manifest: metadata.versions[tagged]}
+ return { resolvedTo: tag, manifest: metadata.versions[tagged] }
} else {
}
diff --git a/lib/utils/proc-log-listener.js b/lib/utils/proc-log-listener.js
index e30ca25fa..1dc4b4399 100644
--- a/lib/utils/proc-log-listener.js
+++ b/lib/utils/proc-log-listener.js
@@ -1,5 +1,5 @@
const log = require('npmlog')
-const {inspect} = require('util')
+const { inspect } = require('util')
module.exports = () => {
process.on('log', (level, ...args) => {
try {
diff --git a/lib/utils/pulse-till-done.js b/lib/utils/pulse-till-done.js
index 6e6783e45..22080739a 100644
--- a/lib/utils/pulse-till-done.js
+++ b/lib/utils/pulse-till-done.js
@@ -20,9 +20,9 @@ module.exports = function (prefix, cb) {
validate('SF', [prefix, cb])
if (!prefix) prefix = 'network'
pulseStart(prefix)
- return (...args) => {
+ return (er, ...args) => {
pulseStop()
- cb(...args)
+ cb(er, ...args)
}
}
module.exports.withPromise = pulseWhile
diff --git a/lib/utils/read-user-info.js b/lib/utils/read-user-info.js
index 6eaad08a1..f5a583be6 100644
--- a/lib/utils/read-user-info.js
+++ b/lib/utils/read-user-info.js
@@ -26,7 +26,7 @@ function readOTP (msg, otp, isRetry) {
}
if (isRetry && otp && /^[\d ]+$|^[A-Fa-f0-9]{64,64}$/.test(otp)) return otp.replace(/\s+/g, '')
- return read({prompt: msg, default: otp || ''})
+ return read({ prompt: msg, default: otp || '' })
.then((otp) => readOTP(msg, otp, true))
}
@@ -34,7 +34,7 @@ function readPassword (msg, password, isRetry) {
if (!msg) msg = 'npm password: '
if (isRetry && password) return password
- return read({prompt: msg, silent: true, default: password || ''})
+ return read({ prompt: msg, silent: true, default: password || '' })
.then((password) => readPassword(msg, password, true))
}
@@ -49,7 +49,7 @@ function readUsername (msg, username, opts, isRetry) {
}
}
- return read({prompt: msg, default: username || ''})
+ return read({ prompt: msg, default: username || '' })
.then((username) => readUsername(msg, username, opts, true))
}
@@ -64,6 +64,6 @@ function readEmail (msg, email, opts, isRetry) {
}
}
- return read({prompt: msg, default: email || ''})
+ return read({ prompt: msg, default: email || '' })
.then((username) => readEmail(msg, username, opts, true))
}
diff --git a/lib/utils/reify-output.js b/lib/utils/reify-output.js
index 810b8e09a..05fc1dce9 100644
--- a/lib/utils/reify-output.js
+++ b/lib/utils/reify-output.js
@@ -24,7 +24,7 @@ const reifyOutput = arb => {
return
}
- const {diff, auditReport, actualTree} = arb
+ const { diff, auditReport, actualTree } = arb
const summary = {
added: 0,
@@ -39,13 +39,13 @@ const reifyOutput = arb => {
visit: d => {
switch (d.action) {
case 'REMOVE':
- summary.removed ++
+ summary.removed++
break
case 'ADD':
- summary.added ++
+ summary.added++
break
case 'CHANGE':
- summary.changed ++
+ summary.changed++
break
default:
return
@@ -105,7 +105,7 @@ const packagesChangedMessage = ({ added, removed, changed, audited }) => {
}
} else {
if (added) {
- msg.push(`added ${added} package${ added === 1 ? '' : 's' }`)
+ msg.push(`added ${added} package${added === 1 ? '' : 's'}`)
}
if (removed) {
if (added) {
@@ -114,7 +114,7 @@ const packagesChangedMessage = ({ added, removed, changed, audited }) => {
if (added && !audited && !changed) {
msg.push('and ')
}
- msg.push(`removed ${removed} package${ removed === 1 ? '' : 's' }`)
+ msg.push(`removed ${removed} package${removed === 1 ? '' : 's'}`)
}
if (changed) {
if (added || removed) {
@@ -123,14 +123,14 @@ const packagesChangedMessage = ({ added, removed, changed, audited }) => {
if (!audited && (added || removed)) {
msg.push('and ')
}
- msg.push(`changed ${changed} package${ changed === 1 ? '' : 's' }`)
+ msg.push(`changed ${changed} package${changed === 1 ? '' : 's'}`)
}
if (audited) {
msg.push(', and ')
}
}
if (audited) {
- msg.push(`audited ${audited} package${ audited === 1 ? '' : 's' }`)
+ msg.push(`audited ${audited} package${audited === 1 ? '' : 's'}`)
}
msg.push(` in ${ms(Date.now() - npm.started)}`)
output(msg.join(''))
diff --git a/lib/utils/setup-log.js b/lib/utils/setup-log.js
index 45077158d..34ff23306 100644
--- a/lib/utils/setup-log.js
+++ b/lib/utils/setup-log.js
@@ -15,16 +15,15 @@ module.exports = (config) => {
const stdoutTTY = process.stdout.isTTY
const stderrTTY = process.stderr.isTTY
const dumbTerm = process.env.TERM === 'dumb'
- const stdoutNotDumb = stdoutTTY && !dumbTerm
const stderrNotDumb = stderrTTY && !dumbTerm
const enableColorStderr = color === 'always' ? true
: color === false ? false
- : stderrTTY
+ : stderrTTY
const enableColorStdout = color === 'always' ? true
: color === false ? false
- : stdoutTTY
+ : stdoutTTY
if (enableColorStderr) {
log.enableColor()
diff --git a/lib/utils/update-notifier.js b/lib/utils/update-notifier.js
index a6abe948b..7ae4a03c3 100644
--- a/lib/utils/update-notifier.js
+++ b/lib/utils/update-notifier.js
@@ -17,7 +17,7 @@ module.exports = (npm) => {
}
const pkg = require('../../package.json')
- const notifier = require('update-notifier')({pkg})
+ const notifier = require('update-notifier')({ pkg })
const ciDetect = require('@npmcli/ci-detect')
if (
notifier.update &&
@@ -32,8 +32,8 @@ module.exports = (npm) => {
const type = notifier.update.type
const typec = !useColor ? type
: type === 'major' ? chalk.red(type)
- : type === 'minor' ? chalk.yellow(type)
- : chalk.green(type)
+ : type === 'minor' ? chalk.yellow(type)
+ : chalk.green(type)
const changelog = `https://github.com/npm/cli/releases/tag/v${latest}`
notifier.notify({
diff --git a/lib/view.js b/lib/view.js
index a9511c22b..34a4a6569 100644
--- a/lib/view.js
+++ b/lib/view.js
@@ -137,7 +137,7 @@ function fetchAndRead (nv, args, silent, opts, cb) {
if (data.time && data.time.unpublished) {
const u = data.time.unpublished
- let er = new Error('Unpublished by ' + u.name + ' on ' + u.time)
+ const er = new Error('Unpublished by ' + u.name + ' on ' + u.time)
er.statusCode = 404
er.code = 'E404'
er.pkgid = data._id
@@ -145,7 +145,7 @@ function fetchAndRead (nv, args, silent, opts, cb) {
}
const results = []
- let error = null
+ const error = null
const versions = data.versions || {}
data.versions = Object.keys(versions).sort(semver.compareLoose)
if (!args.length) args = ['']
@@ -187,8 +187,8 @@ function fetchAndRead (nv, args, silent, opts, cb) {
results.map((v) => prettyView(data, v[Object.keys(v)[0]][''], opts))
).then(() => retval)
} else {
- return new Promise((res, rej) => {
- printData(retval, data._id, opts, er => er ? rej(er) : res())
+ return new Promise((resolve, reject) => {
+ printData(retval, data._id, opts, er => er ? reject(er) : resolve())
}).then(() => retval)
}
}).then(() => cb(), cb)
@@ -299,7 +299,7 @@ function prettyView (packument, manifest, opts) {
if (info.deps.length) {
console.log('')
console.log('dependencies:')
- console.log(columns(info.deps.slice(0, maxDeps), {padding: 1}))
+ console.log(columns(info.deps.slice(0, maxDeps), { padding: 1 }))
if (info.deps.length > maxDeps) {
console.log(`(...and ${info.deps.length - maxDeps} more.)`)
}
@@ -357,6 +357,8 @@ function showFields (data, version, fields) {
return search(o, fields.split('.'), version.version, fields)
}
+const hasOwnProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
+
function search (data, fields, version, title) {
let field
const tail = fields
@@ -373,7 +375,7 @@ function search (data, fields, version, title) {
if (index) {
field = index[1]
index = index[2]
- if (data.field && data.field.hasOwnProperty(index)) {
+ if (data.field && hasOwnProperty(data.field, index)) {
return search(data[field][index], tail, version, title)
} else {
field = field + '[' + index + ']'
@@ -393,7 +395,7 @@ function search (data, fields, version, title) {
results = results.reduce(reducer, {})
return results
}
- if (!data.hasOwnProperty(field)) return undefined
+ if (!hasOwnProperty(data, field)) return undefined
data = data[field]
if (tail.length) {
if (typeof data === 'object') {
diff --git a/lib/xmas.js b/lib/xmas.js
index 81ab59c8e..a80c75e7e 100644
--- a/lib/xmas.js
+++ b/lib/xmas.js
@@ -54,8 +54,10 @@ module.exports = function (args, cb) {
cb()
}
var dg = false
-Object.defineProperty(module.exports, 'usage', {get: function () {
- if (dg) module.exports([], function () {})
- dg = true
- return ' '
-}})
+Object.defineProperty(module.exports, 'usage', {
+ get: function () {
+ if (dg) module.exports([], function () {})
+ dg = true
+ return ' '
+ }
+})