diff options
137 files changed, 898 insertions, 913 deletions
diff --git a/bin/npm-cli.js b/bin/npm-cli.js index e2c013b5d..e73ad028a 100755 --- a/bin/npm-cli.js +++ b/bin/npm-cli.js @@ -1,7 +1,7 @@ #!/usr/bin/env node ;(function () { // wrapper in case we're in module_context mode // windows: running "npm blah" in this folder will invoke WSH, not node. - /*global WScript*/ + /* global WScript */ if (typeof WScript !== 'undefined') { WScript.echo( 'npm does not work when run\n' + diff --git a/lib/access.js b/lib/access.js index ad7a1f54b..164ea3b7d 100644 --- a/lib/access.js +++ b/lib/access.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable standard/no-callback-literal */ var resolve = require('path').resolve @@ -21,7 +22,7 @@ access.usage = 'npm access edit [<package>]' access.subcommands = ['public', 'restricted', 'grant', 'revoke', - 'ls-packages', 'ls-collaborators', 'edit'] + 'ls-packages', 'ls-collaborators', 'edit'] access.completion = function (opts, cb) { var argv = opts.conf.argv.remain diff --git a/lib/adduser.js b/lib/adduser.js index 0aac6b7fb..e1c221032 100644 --- a/lib/adduser.js +++ b/lib/adduser.js @@ -17,7 +17,7 @@ adduser.usage = usage( function adduser (args, cb) { if (!crypto) { return cb(new Error( - 'You must compile node with ssl support to use the adduser feature' + 'You must compile node with ssl support to use the adduser feature' )) } diff --git a/lib/auth/legacy.js b/lib/auth/legacy.js index 08de61bff..cb27a1edc 100644 --- a/lib/auth/legacy.js +++ b/lib/auth/legacy.js @@ -42,38 +42,38 @@ module.exports.login = (creds, registry, scope, cb) => { function login (conf) { return profile.login(openerPromise, loginPrompter, conf) - .catch((err) => { - if (err.code === 'EOTP') throw err - const u = conf.creds.username - const p = conf.creds.password - const e = conf.creds.email - if (!(u && p && e)) throw err - return profile.adduserCouch(u, e, p, conf) - }) - .catch((err) => { - if (err.code !== 'EOTP') throw err - return read.otp('Authenticator provided OTP:').then((otp) => { - conf.auth.otp = otp + .catch((err) => { + if (err.code === 'EOTP') throw err const u = conf.creds.username const p = conf.creds.password - return profile.loginCouch(u, p, conf) + const e = conf.creds.email + if (!(u && p && e)) throw err + return profile.adduserCouch(u, e, p, conf) }) - }).then((result) => { - const newCreds = {} - if (result && result.token) { - newCreds.token = result.token - } else { - newCreds.username = conf.creds.username - newCreds.password = conf.creds.password - newCreds.email = conf.creds.email - newCreds.alwaysAuth = npm.config.get('always-auth') - } + .catch((err) => { + if (err.code !== 'EOTP') throw err + return read.otp('Authenticator provided OTP:').then((otp) => { + conf.auth.otp = otp + const u = conf.creds.username + const p = conf.creds.password + return profile.loginCouch(u, p, conf) + }) + }).then((result) => { + const newCreds = {} + if (result && result.token) { + newCreds.token = result.token + } else { + newCreds.username = conf.creds.username + newCreds.password = conf.creds.password + newCreds.email = conf.creds.email + newCreds.alwaysAuth = npm.config.get('always-auth') + } - const usermsg = conf.creds.username ? ' user ' + conf.creds.username : '' - conf.log.info('login', 'Authorized' + usermsg) - const scopeMessage = conf.scope ? ' to scope ' + conf.scope : '' - const userout = conf.creds.username ? ' as ' + conf.creds.username : '' - output('Logged in%s%s on %s.', userout, scopeMessage, conf.registry) - return newCreds - }) + const usermsg = conf.creds.username ? ' user ' + conf.creds.username : '' + conf.log.info('login', 'Authorized' + usermsg) + const scopeMessage = conf.scope ? ' to scope ' + conf.scope : '' + const userout = conf.creds.username ? ' as ' + conf.creds.username : '' + output('Logged in%s%s on %s.', userout, scopeMessage, conf.registry) + return newCreds + }) } diff --git a/lib/build.js b/lib/build.js index 395f9437b..f8b3c4933 100644 --- a/lib/build.js +++ b/lib/build.js @@ -106,7 +106,7 @@ function rebuildBundles (pkg, folder, cb) { if (!npm.config.get('rebuild-bundle')) return cb() var deps = Object.keys(pkg.dependencies || {}) - .concat(Object.keys(pkg.devDependencies || {})) + .concat(Object.keys(pkg.devDependencies || {})) var bundles = pkg.bundleDependencies || pkg.bundledDependencies || [] fs.readdir(path.resolve(folder, 'node_modules'), function (er, files) { @@ -119,7 +119,7 @@ function rebuildBundles (pkg, folder, cb) { chain(files.filter(function (file) { // rebuild if: // not a .folder, like .bin or .hooks - return !file.match(/^[\._-]/) && + return !file.match(/^[._-]/) && // not some old 0.x style bundle file.indexOf('@') === -1 && // either not a dep, or explicitly bundled diff --git a/lib/cache.js b/lib/cache.js index 8bd2d5fcb..d80f196c8 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable standard/no-callback-literal */ const BB = require('bluebird') @@ -27,11 +27,11 @@ function ci (args, cb) { config: npm.config, log: npmlog }) - .run() - .then( - (details) => console.error(`added ${details.pkgCount} packages in ${ - details.runTime / 1000 - }s`) - ) - .then(() => cb(), cb) + .run() + .then( + (details) => console.error(`added ${details.pkgCount} packages in ${ + details.runTime / 1000 + }s`) + ) + .then(() => cb(), cb) } diff --git a/lib/completion.js b/lib/completion.js index 3157255bf..a682c134a 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -49,7 +49,7 @@ function completion (args, cb) { if (isWindowsShell) { var e = new Error('npm completion supported only in MINGW / Git bash on Windows') e.code = 'ENOTSUP' - e.errno = require('constants').ENOTSUP + e.errno = require('constants').ENOTSUP // eslint-disable-line node/no-deprecated-api return cb(e) } @@ -150,7 +150,7 @@ function dumpScript (cb) { fs.readFile(p, 'utf8', function (er, d) { if (er) return cb(er) - d = d.replace(/^\#\!.*?\n/, '') + d = d.replace(/^#!.*?\n/, '') process.stdout.write(d, function () { cb() }) process.stdout.on('error', function (er) { diff --git a/lib/config.js b/lib/config.js index d260c04a5..a6862808f 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ module.exports = config var log = require('npmlog') @@ -39,7 +40,7 @@ config.completion = function (opts, cb) { // todo: complete with valid values, if possible. if (argv.length > 3) return cb(null, []) // fallthrough - /*eslint no-fallthrough:0*/ + /* eslint no-fallthrough:0 */ case 'get': case 'delete': case 'rm': @@ -89,7 +90,7 @@ function edit (cb) { data = [ ';;;;', '; npm ' + (npm.config.get('global') - ? 'globalconfig' : 'userconfig') + ' file', + ? 'globalconfig' : 'userconfig') + ' file', '; this is a simple ini-formatted file', '; lines that start with semi-colons are comments.', '; read `npm help config` for help on the various options', @@ -111,8 +112,8 @@ function edit (cb) { .replace(/\n/g, '\n; ') .split('\n')) }, [])) - .concat(['']) - .join(os.EOL) + .concat(['']) + .join(os.EOL) writeFileAtomic( f, data, diff --git a/lib/config/core.js b/lib/config/core.js index 54a74bb84..4c542bc45 100644 --- a/lib/config/core.js +++ b/lib/config/core.js @@ -21,18 +21,20 @@ exports.defs = configDefs Object.defineProperty(exports, 'defaults', { get: function () { return configDefs.defaults -}, enumerable: true }) +}, +enumerable: true }) Object.defineProperty(exports, 'types', { get: function () { return configDefs.types -}, enumerable: true }) +}, +enumerable: true }) exports.validate = validate var myUid = process.env.SUDO_UID !== undefined - ? process.env.SUDO_UID : (process.getuid && process.getuid()) + ? process.env.SUDO_UID : (process.getuid && process.getuid()) var myGid = process.env.SUDO_GID !== undefined - ? process.env.SUDO_GID : (process.getgid && process.getgid()) + ? process.env.SUDO_GID : (process.getgid && process.getgid()) var loading = false var loadCbs = [] @@ -274,7 +276,7 @@ Conf.prototype.save = function (where, cb) { if (cb) return cb(er) else return this.emit('error', er) } - this._saving -- + this._saving-- if (this._saving === 0) { if (cb) cb() this.emit('save') @@ -283,7 +285,7 @@ Conf.prototype.save = function (where, cb) { then = then.bind(this) done = done.bind(this) - this._saving ++ + this._saving++ var mode = where === 'user' ? '0600' : '0666' if (!data.trim()) { @@ -354,8 +356,8 @@ Conf.prototype.addEnv = function (env) { // leave first char untouched, even if // it is a '_' - convert all other to '-' var p = k.toLowerCase() - .replace(/^npm_config_/, '') - .replace(/(?!^)_/g, '-') + .replace(/^npm_config_/, '') + .replace(/(?!^)_/g, '-') conf[p] = env[k] }) return CC.prototype.addEnv.call(this, '', conf, 'env') diff --git a/lib/config/defaults.js b/lib/config/defaults.js index 865805eb2..43c3f5ba0 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -82,7 +82,7 @@ if (home) process.env.HOME = home else home = path.resolve(temp, 'npm-' + uidOrPid) var cacheExtra = process.platform === 'win32' ? 'npm-cache' : '.npm' -var cacheRoot = process.platform === 'win32' && process.env.APPDATA || home +var cacheRoot = (process.platform === 'win32' && process.env.APPDATA) || home var cache = path.resolve(cacheRoot, cacheExtra) var globalPrefix @@ -152,7 +152,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { globalconfig: path.resolve(globalPrefix, 'etc', 'npmrc'), 'global-style': false, group: process.platform === 'win32' ? 0 - : process.env.SUDO_GID || (process.getgid && process.getgid()), + : process.env.SUDO_GID || (process.getgid && process.getgid()), 'ham-it-up': false, heading: 'npm', 'if-present': false, @@ -384,9 +384,9 @@ function getLocalAddresses () { return interfaces[nic].filter(function (addr) { return addr.family === 'IPv4' }) - .map(function (addr) { - return addr.address - }) + .map(function (addr) { + return addr.address + }) }).reduce(function (curr, next) { return curr.concat(next) }, []).concat(undefined) diff --git a/lib/config/fetch-opts.js b/lib/config/fetch-opts.js index 1a030c378..213c293d6 100644 --- a/lib/config/fetch-opts.js +++ b/lib/config/fetch-opts.js @@ -26,12 +26,12 @@ function fromPacote (opts) { function getCacheMode (opts) { return opts.offline - ? 'only-if-cached' - : opts.preferOffline - ? 'force-cache' - : opts.preferOnline - ? 'no-cache' - : 'default' + ? 'only-if-cached' + : opts.preferOffline + ? 'force-cache' + : opts.preferOnline + ? 'no-cache' + : 'default' } function getHeaders (uri, registry, opts) { diff --git a/lib/config/get-credentials-by-uri.js b/lib/config/get-credentials-by-uri.js index d04f6137d..5e672696b 100644 --- a/lib/config/get-credentials-by-uri.js +++ b/lib/config/get-credentials-by-uri.js @@ -40,14 +40,14 @@ function getCredentialsByURI (uri) { var userDef = this.get('username') var passDef = this.get('_password') if (authDef && !(userDef && passDef)) { - authDef = new Buffer(authDef, 'base64').toString() + authDef = Buffer.from(authDef, 'base64').toString() authDef = authDef.split(':') userDef = authDef.shift() passDef = authDef.join(':') } if (this.get(nerfed + ':_password')) { - c.password = new Buffer(this.get(nerfed + ':_password'), 'base64').toString('utf8') + c.password = Buffer.from(this.get(nerfed + ':_password'), 'base64').toString('utf8') } else if (nerfed === defnerf && passDef) { c.password = passDef } @@ -65,7 +65,7 @@ function getCredentialsByURI (uri) { } if (c.username && c.password) { - c.auth = new Buffer(c.username + ':' + c.password).toString('base64') + c.auth = Buffer.from(c.username + ':' + c.password).toString('base64') } return c diff --git a/lib/config/load-prefix.js b/lib/config/load-prefix.js index c2af00c7f..090865d21 100644 --- a/lib/config/load-prefix.js +++ b/lib/config/load-prefix.js @@ -34,7 +34,7 @@ function loadPrefix (cb) { Object.defineProperty(this, 'localPrefix', { 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/set-credentials-by-uri.js b/lib/config/set-credentials-by-uri.js index 74211380d..4723d561a 100644 --- a/lib/config/set-credentials-by-uri.js +++ b/lib/config/set-credentials-by-uri.js @@ -23,7 +23,7 @@ function setCredentialsByURI (uri, c) { this.del(nerfed + ':_authToken', 'user') - var encoded = new Buffer(c.password, 'utf8').toString('base64') + var encoded = Buffer.from(c.password, 'utf8').toString('base64') this.set(nerfed + ':_password', encoded, 'user') this.set(nerfed + ':username', c.username, 'user') this.set(nerfed + ':email', c.email, 'user') diff --git a/lib/deprecate.js b/lib/deprecate.js index 15ae58e01..9b71d1de4 100644 --- a/lib/deprecate.js +++ b/lib/deprecate.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ var npm = require('./npm.js') var mapToRegistry = require('./utils/map-to-registry.js') var npa = require('npm-package-arg') diff --git a/lib/dist-tag.js b/lib/dist-tag.js index 7c20ea990..bd0c5ae8a 100644 --- a/lib/dist-tag.js +++ b/lib/dist-tag.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ module.exports = distTag var log = require('npmlog') diff --git a/lib/edit.js b/lib/edit.js index 8e9bbd179..48bcd5d34 100644 --- a/lib/edit.js +++ b/lib/edit.js @@ -22,8 +22,8 @@ function edit (args, cb) { )) } p = p.split('/') - .join('/node_modules/') - .replace(/(\/node_modules)+/, '/node_modules') + .join('/node_modules/') + .replace(/(\/node_modules)+/, '/node_modules') var f = path.resolve(npm.dir, p) fs.lstat(f, function (er) { if (er) return cb(er) diff --git a/lib/help-search.js b/lib/help-search.js index ffbe554b7..475f305e4 100644 --- a/lib/help-search.js +++ b/lib/help-search.js @@ -70,7 +70,7 @@ function searchFiles (args, files, cb) { if (nextLine) { for (a = 0, ll = args.length; a < ll && !match; a++) { match = nextLine.toLowerCase() - .indexOf(args[a].toLowerCase()) !== -1 + .indexOf(args[a].toLowerCase()) !== -1 } if (match) { // skip over the next line, and the line after it. @@ -107,7 +107,7 @@ function searchFiles (args, files, cb) { lines.forEach(function (line) { args.forEach(function (arg) { var hit = (line || '').toLowerCase() - .split(arg.toLowerCase()).length - 1 + .split(arg.toLowerCase()).length - 1 if (hit > 0) { found[arg] = (found[arg] || 0) + hit totalHits += hit @@ -144,12 +144,12 @@ function searchFiles (args, files, cb) { // then by number of matching lines results = results.sort(function (a, b) { return a.found.length > b.found.length ? -1 - : a.found.length < b.found.length ? 1 - : a.totalHits > b.totalHits ? -1 - : a.totalHits < b.totalHits ? 1 - : a.lines.length > b.lines.length ? -1 - : a.lines.length < b.lines.length ? 1 - : 0 + : a.found.length < b.found.length ? 1 + : a.totalHits > b.totalHits ? -1 + : a.totalHits < b.totalHits ? 1 + : a.lines.length > b.lines.length ? -1 + : a.lines.length < b.lines.length ? 1 + : 0 }) cb(null, results) @@ -170,7 +170,7 @@ function formatResults (args, results, cb) { }).join(' ') out += ((new Array(Math.max(1, cols - out.length - r.length))) - .join(' ')) + r + .join(' ')) + r if (!npm.config.get('long')) return out diff --git a/lib/help.js b/lib/help.js index 64c80f787..acc1243d2 100644 --- a/lib/help.js +++ b/lib/help.js @@ -97,8 +97,8 @@ function pickMan (mans, pref_) { var an = a.match(nre)[1] var bn = b.match(nre)[1] return an === bn ? (a > b ? -1 : 1) - : pref[an] < pref[bn] ? -1 - : 1 + : pref[an] < pref[bn] ? -1 + : 1 }) return mans[0] } @@ -168,7 +168,7 @@ function npmUsage (valid, cb) { '', 'where <command> is one of:', npm.config.get('long') ? usages() - : ' ' + wrap(commands), + : ' ' + wrap(commands), '', 'npm <command> -h quick help on <command>', 'npm -l display full usage info', diff --git a/lib/install.js b/lib/install.js index 7a7d75c90..4f913e00a 100644 --- a/lib/install.js +++ b/lib/install.js @@ -1,4 +1,6 @@ 'use strict' +/* eslint-disable camelcase */ +/* eslint-disable standard/no-callback-literal */ // npm install <pkg> <pkg> <pkg> // // See doc/cli/npm-install.md for more description @@ -181,8 +183,8 @@ function install (where, args, cb) { var globalTop = path.resolve(npm.globalDir, '..') if (!where) { where = npm.config.get('global') - ? globalTop - : npm.prefix + ? globalTop + : npm.prefix } validate('SAF', [where, args, cb]) // the /path/to/node_modules/.. diff --git a/lib/install/action/fetch.js b/lib/install/action/fetch.js index a4d760fe8..5ad34e29d 100644 --- a/lib/install/action/fetch.js +++ b/lib/install/action/fetch.js @@ -12,5 +12,5 @@ function fetch (staging, pkg, log, next) { log.silly('fetch', packageId(pkg)) const opts = pacoteOpts({integrity: pkg.package._integrity}) return finished(pacote.tarball.stream(pkg.package._requested, opts)) - .then(() => next(), next) + .then(() => next(), next) } diff --git a/lib/install/deps.js b/lib/install/deps.js index d3b31ac09..2a0fc8d90 100644 --- a/lib/install/deps.js +++ b/lib/install/deps.js @@ -66,7 +66,7 @@ function doesChildVersionMatch (child, requested, requestor) { // You'll see this scenario happen with at least tags and git dependencies. // Some buggy clients will write spaces into the module name part of a _from. if (child.package._from) { - var fromReq = npa.resolve(moduleName(child), child.package._from.replace(new RegExp('^\s*' + moduleName(child) + '\s*@'), '')) + var fromReq = npa.resolve(moduleName(child), child.package._from.replace(new RegExp('^\\s*' + moduleName(child) + '\\s*@'), '')) if (fromReq.rawSpec === requested.rawSpec) return true if (fromReq.type === requested.type && fromReq.saveSpec && fromReq.saveSpec === requested.saveSpec) return true } @@ -105,7 +105,6 @@ function computeMetadata (tree, seen) { resolveWithExistingModule(child, tree) return true } - return } const deps = tree.package.dependencies || {} @@ -187,15 +186,14 @@ function packageRelativePath (tree) { var requested = tree.package._requested || {} var isLocal = requested.type === 'directory' || requested.type === 'file' return isLocal ? requested.fetchSpec - : (tree.isLink || tree.isInLink) && !preserveSymlinks() ? tree.realpath - : tree.path + : (tree.isLink || tree.isInLink) && !preserveSymlinks() ? tree.realpath + : tree.path } function matchingDep (tree, name) { if (!tree || !tree.package) return if (tree.package.dependencies && tree.package.dependencies[name]) return tree.package.dependencies[name] if (tree.package.devDependencies && tree.package.devDependencies[name]) return tree.package.devDependencies[name] - return } exports.getAllMetadata = function (args, tree, where, next) { diff --git a/lib/install/diff-trees.js b/lib/install/diff-trees.js index 06e6b77a9..0e9ec7872 100644 --- a/lib/install/diff-trees.js +++ b/lib/install/diff-trees.js @@ -50,7 +50,7 @@ function pkgIntegrity (pkg) { if (Object.keys(integrity).length === 0) return return integrity } catch (ex) { - return + } } diff --git a/lib/install/read-shrinkwrap.js b/lib/install/read-shrinkwrap.js index 2d469864f..707467801 100644 --- a/lib/install/read-shrinkwrap.js +++ b/lib/install/read-shrinkwrap.js @@ -52,9 +52,9 @@ module.exports.andInflate = function (child, next) { } const PARENT_RE = /\|{7,}/g -const OURS_RE = /\<{7,}/g -const THEIRS_RE = /\={7,}/g -const END_RE = /\>{7,}/g +const OURS_RE = /<{7,}/g +const THEIRS_RE = /={7,}/g +const END_RE = />{7,}/g module.exports._isDiff = isDiff function isDiff (str) { diff --git a/lib/link.js b/lib/link.js index 158d9b064..e05526c40 100644 --- a/lib/link.js +++ b/lib/link.js @@ -25,7 +25,7 @@ link.completion = function (opts, cb) { var dir = npm.globalDir fs.readdir(dir, function (er, files) { cb(er, files.filter(function (f) { - return !f.match(/^[\._-]/) + return !f.match(/^[._-]/) })) }) } @@ -37,7 +37,7 @@ function link (args, cb) { var msg = 'npm link not supported on windows prior to node 0.7.9' var e = new Error(msg) e.code = 'ENOTSUP' - e.errno = require('constants').ENOTSUP + e.errno = require('constants').ENOTSUP // eslint-disable-line node/no-deprecated-api return cb(e) } } @@ -148,8 +148,8 @@ function linkPkg (folder, cb_) { er = new Error('Package must have a name field to be linked') return cb(er) } - if (npm.config.get('dry-run')) return resultPrinter(path.basename(me), me, target, cb) var target = path.resolve(npm.globalDir, d.name) + if (npm.config.get('dry-run')) return resultPrinter(path.basename(me), me, target, cb) symlink(me, target, false, true, function (er) { if (er) return cb(er) log.verbose('link', 'build target', target) @@ -139,9 +139,9 @@ function filterByEnv (data) { return } - if ((dev && inList(devKeys, name)) || // only --dev - (production && inList(prodKeys, name)) || // only --production - (!dev && !production)) { // no --production|--dev|--only=xxx + if ((dev && inList(devKeys, name)) || // only --dev + (production && inList(prodKeys, name)) || // only --production + (!dev && !production)) { // no --production|--dev|--only=xxx dependencies[name] = data.dependencies[name] } }) @@ -165,7 +165,7 @@ function alphasort (a, b) { a = a.toLowerCase() b = b.toLowerCase() return a > b ? 1 - : a < b ? -1 : 0 + : a < b ? -1 : 0 } function isCruft (data) { @@ -520,16 +520,16 @@ function makeParseable_ (data, long, dir, depth, parent, d) { if (data.missing) { if (depth < npm.config.get('depth')) { data = npm.config.get('long') - ? path.resolve(parent.path, 'node_modules', d) + + ? path.resolve(parent.path, 'node_modules', d) + ':' + d + '@' + JSON.stringify(data.requiredBy) + ':INVALID:MISSING' - : '' + : '' } else { data = path.resolve(dir || '', 'node_modules', d || '') + (npm.config.get('long') - ? ':' + d + '@' + JSON.stringify(data.requiredBy) + + ? ':' + d + '@' + JSON.stringify(data.requiredBy) + ':' + // no realpath resolved ':MAXDEPTH' - : '') + : '') } return data diff --git a/lib/npm.js b/lib/npm.js index e58712603..2ff217c24 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -1,6 +1,6 @@ ;(function () { // windows: running 'npm blah' in this folder will invoke WSH, not node. - /*globals WScript*/ + /* globals WScript */ if (typeof WScript !== 'undefined') { WScript.echo( 'npm does not work when run\n' + @@ -164,11 +164,13 @@ }) return commandCache[a] - }, enumerable: fullList.indexOf(c) !== -1, configurable: true }) + }, + enumerable: fullList.indexOf(c) !== -1, + configurable: true }) // make css-case commands callable via camelCase as well - if (c.match(/\-([a-z])/)) { - addCommand(c.replace(/\-([a-z])/g, function (a, b) { + if (c.match(/-([a-z])/)) { + addCommand(c.replace(/-([a-z])/g, function (a, b) { return b.toUpperCase() })) } @@ -411,8 +413,8 @@ { get: function () { return (process.platform !== 'win32') - ? path.resolve(npm.globalPrefix, 'lib', 'node_modules') - : path.resolve(npm.globalPrefix, 'node_modules') + ? path.resolve(npm.globalPrefix, 'lib', 'node_modules') + : path.resolve(npm.globalPrefix, 'node_modules') }, enumerable: true }) @@ -455,7 +457,9 @@ } npm.commands[n](args, cb) } - }, enumerable: false, configurable: true }) + }, + enumerable: false, + configurable: true }) }) if (require.main === module) { diff --git a/lib/outdated.js b/lib/outdated.js index 5cae20043..8b0a43d6b 100644 --- a/lib/outdated.js +++ b/lib/outdated.js @@ -89,11 +89,11 @@ function outdated (args, silent, cb) { } else { var outList = list.map(makePretty) var outHead = [ 'Package', - 'Current', - 'Wanted', - 'Latest', - 'Location' - ] + 'Current', + 'Wanted', + 'Latest', + 'Location' + ] if (long) outHead.push('Package Type') var outTable = [outHead].concat(outList) @@ -117,25 +117,19 @@ function outdated (args, silent, cb) { // [[ dir, dep, has, want, latest, type ]] function makePretty (p) { - var dep = p[0] var depname = p[1] - var dir = dep.path var has = p[2] var want = p[3] var latest = p[4] var type = p[6] var deppath = p[7] - if (!npm.config.get('global')) { - dir = path.relative(process.cwd(), dir) - } - var columns = [ depname, - has || 'MISSING', - want, - latest, - deppath - ] + has || 'MISSING', + want, + latest, + deppath + ] if (long) columns[5] = type if (npm.color) { @@ -183,10 +177,10 @@ function makeJSON (list) { dir = path.relative(process.cwd(), dir) } out[depname] = { current: has, - wanted: want, - latest: latest, - location: dir - } + wanted: want, + latest: latest, + location: dir + } if (long) out[depname].type = type }) return JSON.stringify(out, null, 2) @@ -317,11 +311,11 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, cb, type) { // show user that no viable version can be found if (er) return cb(er) outdated_(args, - pkgpath, - tree, - has, - depth + 1, - cb) + pkgpath, + tree, + has, + depth + 1, + cb) } function doIt (wanted, latest) { @@ -399,7 +393,7 @@ function shouldUpdate (args, tree, dep, has, req, depth, pkgpath, cb, type) { var cFromUrl = curr && curr.from && url.parse(curr.from).protocol if (!curr || - dFromUrl && cFromUrl && m._from !== curr.from || + (dFromUrl && cFromUrl && m._from !== curr.from) || m.version !== curr.version || m.version !== l.version) { doIt(m.version, l.version) diff --git a/lib/owner.js b/lib/owner.js index 64d086af7..3c2660ace 100644 --- a/lib/owner.js +++ b/lib/owner.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ module.exports = owner var npm = require('./npm.js') @@ -53,7 +54,7 @@ owner.completion = function (opts, cb) { }) } // else fallthrough - /*eslint no-fallthrough:0*/ + /* eslint no-fallthrough:0 */ case 'add': if (argv.length > 3) { theUser = encodeURIComponent(argv[3]) diff --git a/lib/pack.js b/lib/pack.js index dbcbf2967..8ad8fefe5 100644 --- a/lib/pack.js +++ b/lib/pack.js @@ -63,24 +63,24 @@ function pack_ (pkg, dir) { return BB.fromNode((cb) => fpm(pkg, dir, cb)).then((mani) => { let name = mani.name[0] === '@' // scoped packages get special treatment - ? mani.name.substr(1).replace(/\//g, '-') - : mani.name + ? mani.name.substr(1).replace(/\//g, '-') + : mani.name const target = `${name}-${mani.version}.tgz` return pinflight(target, () => { if (mani._requested.type === 'directory') { return cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'packing'}, (tmp) => { const tmpTarget = path.join(tmp, path.basename(target)) return prepareDirectory(mani._resolved) - .then(() => { - return packDirectory(mani, mani._resolved, tmpTarget, target, true) - }) - .tap(() => { - if (npm.config.get('dry-run')) { - log.verbose('pack', '--dry-run mode enabled. Skipping write.') - } else { - return move(tmpTarget, target, {Promise: BB, fs}) - } - }) + .then(() => { + return packDirectory(mani, mani._resolved, tmpTarget, target, true) + }) + .tap(() => { + if (npm.config.get('dry-run')) { + log.verbose('pack', '--dry-run mode enabled. Skipping write.') + } else { + return move(tmpTarget, target, {Promise: BB, fs}) + } + }) }) } else if (npm.config.get('dry-run')) { log.verbose('pack', '--dry-run mode enabled. Skipping write.') @@ -98,12 +98,12 @@ function pack_ (pkg, dir) { function packFromPackage (arg, target, filename) { const opts = pacoteOpts() return pacote.tarball.toFile(arg, target, pacoteOpts()) - .then(() => cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'unpacking'}, (tmp) => { - const tmpTarget = path.join(tmp, filename) - return pacote.extract(arg, tmpTarget, opts) - .then(() => readJson(path.join(tmpTarget, 'package.json'))) - })) - .then((pkg) => getContents(pkg, target, filename)) + .then(() => cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'unpacking'}, (tmp) => { + const tmpTarget = path.join(tmp, filename) + return pacote.extract(arg, tmpTarget, opts) + .then(() => readJson(path.join(tmpTarget, 'package.json'))) + })) + .then((pkg) => getContents(pkg, target, filename)) } module.exports.prepareDirectory = prepareDirectory @@ -238,19 +238,19 @@ function getContents (pkg, target, filename, silent) { }, strip: 1 }) - .then(() => BB.fromNode((cb) => fs.stat(target, cb))) - .then((stat) => ({ - id: pkg._id, - name: pkg.name, - version: pkg.version, - from: pkg._from, - size: stat.size, - unpackedSize: totalEntrySize, - filename, - files, - entryCount: totalEntries, - bundled: Array.from(bundled) - })) + .then(() => BB.fromNode((cb) => fs.stat(target, cb))) + .then((stat) => ({ + id: pkg._id, + name: pkg.name, + version: pkg.version, + from: pkg._from, + size: stat.size, + unpackedSize: totalEntrySize, + filename, + files, + entryCount: totalEntries, + bundled: Array.from(bundled) + })) } const PASSTHROUGH_OPTS = [ diff --git a/lib/profile.js b/lib/profile.js index 016e89815..f57123932 100644 --- a/lib/profile.js +++ b/lib/profile.js @@ -137,7 +137,6 @@ function get (args) { output(`${key}\t${info[key]}`) } }) - return } else { const table = new Table() Object.keys(cleaned).forEach((k) => table.push({[ansistyles.bright(k)]: cleaned[k]})) diff --git a/lib/publish.js b/lib/publish.js index 2f2aa082e..f0616d38d 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -48,15 +48,15 @@ function publish (args, isRetry, cb) { } return publish_(args[0]) - .then((tarball) => { - const silent = log.level === 'silent' - if (!silent && npm.config.get('json')) { - output(JSON.stringify(tarball, null, 2)) - } else if (!silent) { - output(`+ ${tarball.id}`) - } - }) - .nodeify(cb) + .then((tarball) => { + const silent = log.level === 'silent' + if (!silent && npm.config.get('json')) { + output(JSON.stringify(tarball, null, 2)) + } else if (!silent) { + output(`+ ${tarball.id}`) + } + }) + .nodeify(cb) } function publish_ (arg) { @@ -93,9 +93,9 @@ function publishFromDirectory (arg) { return cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'fromDir'}, (tmpDir) => { const target = path.join(tmpDir, 'package.tgz') return pack.packDirectory(pkg, arg, target, null, true) - .tap((c) => { contents = c }) - .then((c) => !npm.config.get('json') && pack.logContents(c)) - .then(() => upload(arg, pkg, false, target)) + .tap((c) => { contents = c }) + .then((c) => !npm.config.get('json') && pack.logContents(c)) + .then(() => upload(arg, pkg, false, target)) }) }).then(() => { return readJson(path.join(arg, 'package.json')) @@ -104,7 +104,7 @@ function publishFromDirectory (arg) { }).tap((pkg) => { return lifecycle(pkg, 'postpublish', arg) }) - .then(() => contents) + .then(() => contents) } function publishFromPackage (arg) { @@ -113,13 +113,13 @@ function publishFromPackage (arg) { const target = path.join(tmp, 'package.json') const opts = pacoteOpts() return pacote.tarball.toFile(arg, target, opts) - .then(() => pacote.extract(arg, extracted, opts)) - .then(() => readJson(path.join(extracted, 'package.json'))) - .then((pkg) => { - return BB.resolve(pack.getContents(pkg, target)) - .tap((c) => !npm.config.get('json') && pack.logContents(c)) - .tap(() => upload(arg, pkg, false, target)) - }) + .then(() => pacote.extract(arg, extracted, opts)) + .then(() => readJson(path.join(extracted, 'package.json'))) + .then((pkg) => { + return BB.resolve(pack.getContents(pkg, target)) + .tap((c) => !npm.config.get('json') && pack.logContents(c)) + .tap(() => upload(arg, pkg, false, target)) + }) }) } diff --git a/lib/repo.js b/lib/repo.js index d7e79d76a..7ad61c97a 100644 --- a/lib/repo.js +++ b/lib/repo.js @@ -43,8 +43,8 @@ function unknownHostedUrl (url) { } url = url_.parse(url) var protocol = url.protocol === 'https:' - ? 'https:' - : 'http:' + ? 'https:' + : 'http:' return protocol + '//' + (url.host || '') + url.path.replace(/\.git$/, '') } catch (e) {} diff --git a/lib/run-script.js b/lib/run-script.js index fb7781f55..639917441 100644 --- a/lib/run-script.js +++ b/lib/run-script.js @@ -32,7 +32,7 @@ runScript.completion = function (opts, cb) { if (scripts.indexOf(argv[2]) !== -1) return cb() // ok, try to find out which package it was, then var pref = npm.config.get('global') ? npm.config.get('prefix') - : npm.localPrefix + : npm.localPrefix var pkgDir = path.resolve(pref, 'node_modules', argv[2], 'package.json') readJson(pkgDir, function (er, d) { if (er && er.code !== 'ENOENT' && er.code !== 'ENOTDIR') return cb(er) diff --git a/lib/search/format-package-stream.js b/lib/search/format-package-stream.js index a312e3f48..bb0f552ba 100644 --- a/lib/search/format-package-stream.js +++ b/lib/search/format-package-stream.js @@ -50,8 +50,8 @@ function prettify (data, num, opts) { var pkg = normalizePackage(data, opts) var columns = opts.description - ? ['name', 'description', 'author', 'date', 'version', 'keywords'] - : ['name', 'author', 'date', 'version', 'keywords'] + ? ['name', 'description', 'author', 'date', 'version', 'keywords'] + : ['name', 'author', 'date', 'version', 'keywords'] if (opts.parseable) { return columns.map(function (col) { @@ -157,16 +157,16 @@ function normalizePackage (data, opts) { return '=' + m.username }).join(' '), keywords: Array.isArray(data.keywords) - ? data.keywords.join(' ') - : typeof data.keywords === 'string' - ? data.keywords.replace(/[,\s]+/, ' ') - : '', + ? data.keywords.join(' ') + : typeof data.keywords === 'string' + ? data.keywords.replace(/[,\s]+/, ' ') + : '', version: data.version, - date: data.date && + date: (data.date && (data.date.toISOString() // remove time .split('T').join(' ') .replace(/:[0-9]{2}\.[0-9]{3}Z$/, '')) - .slice(0, -5) || + .slice(0, -5)) || 'prehistoric' } } diff --git a/lib/search/package-filter.js b/lib/search/package-filter.js index ac2950f46..892adb08c 100644 --- a/lib/search/package-filter.js +++ b/lib/search/package-filter.js @@ -8,16 +8,16 @@ function filter (data, include, exclude, opts) { function getWords (data, opts) { return [ data.name ] - .concat((opts && opts.description) ? data.description : []) - .concat((data.maintainers || []).map(function (m) { - return '=' + m.name - })) - .concat(data.versions && data.versions.length && data.url && ('<' + data.url + '>')) - .concat(data.keywords || []) - .map(function (f) { return f && f.trim && f.trim() }) - .filter(function (f) { return f }) - .join(' ') - .toLowerCase() + .concat((opts && opts.description) ? data.description : []) + .concat((data.maintainers || []).map(function (m) { + return '=' + m.name + })) + .concat(data.versions && data.versions.length && data.url && ('<' + data.url + '>')) + .concat(data.keywords || []) + .map(function (f) { return f && f.trim && f.trim() }) + .filter(function (f) { return f }) + .join(' ') + .toLowerCase() } function filterWords (data, include, exclude, opts) { diff --git a/lib/team.js b/lib/team.js index f99063b27..1e0a09496 100644 --- a/lib/team.js +++ b/lib/team.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ var mapToRegistry = require('./utils/map-to-registry.js') var npm = require('./npm') var output = require('./utils/output.js') diff --git a/lib/test.js b/lib/test.js index 06138ac00..05bffed86 100644 --- a/lib/test.js +++ b/lib/test.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ module.exports = test const testCmd = require('./utils/lifecycle-cmd.js')('test') diff --git a/lib/unbuild.js b/lib/unbuild.js index 78293c9ca..d527778e9 100644 --- a/lib/unbuild.js +++ b/lib/unbuild.js @@ -77,7 +77,7 @@ function rmBins (pkg, folder, parent, top, cb) { asyncMap(Object.keys(pkg.bin), function (b, cb) { if (process.platform === 'win32') { chain([ [gentlyRm, path.resolve(binRoot, b) + '.cmd', true, folder], - [gentlyRm, path.resolve(binRoot, b), true, folder] ], cb) + [gentlyRm, path.resolve(binRoot, b), true, folder] ], cb) } else { gentlyRm(path.resolve(binRoot, b), true, folder, cb) } diff --git a/lib/uninstall.js b/lib/uninstall.js index 333d3e9d6..c4bd23ea3 100644 --- a/lib/uninstall.js +++ b/lib/uninstall.js @@ -29,8 +29,8 @@ function uninstall (args, cb) { if (args.length === 1 && args[0] === '.') args = [] const where = npm.config.get('global') || !args.length - ? path.resolve(npm.globalDir, '..') - : npm.prefix + ? path.resolve(npm.globalDir, '..') + : npm.prefix args = args.filter(function (a) { return path.resolve(a) !== where diff --git a/lib/unpublish.js b/lib/unpublish.js index 4ea818702..c2e9edd80 100644 --- a/lib/unpublish.js +++ b/lib/unpublish.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ module.exports = unpublish @@ -100,10 +101,10 @@ function gotProject (project, version, publishConfig, cb_) { // remove from the cache first // npm.commands.cache(['clean', project, version], function (er) { - // if (er) { - // log.error('unpublish', 'Failed to clean cache') - // return cb(er) - // } + // if (er) { + // log.error('unpublish', 'Failed to clean cache') + // return cb(er) + // } mapToRegistry(project, config, function (er, uri, auth) { if (er) return cb(er) diff --git a/lib/update.js b/lib/update.js index efb56f5e4..9b1345f9d 100644 --- a/lib/update.js +++ b/lib/update.js @@ -57,7 +57,7 @@ function update_ (args) { // use the initial installation method (repo, tar, git) for updating if (url.parse(ww.req).protocol) ww.what = ww.req - const where = ww.dep.parent && ww.dep.parent.path || ww.dep.path + const where = (ww.dep.parent && ww.dep.parent.path) || ww.dep.path const isTransitive = !(ww.dep.requiredBy || []).some((p) => p.isTop) const key = where + ':' + String(isTransitive) if (!toInstall[key]) toInstall[key] = {where: where, opts: {saveOnlyLock: isTransitive}, what: []} diff --git a/lib/utils/error-handler.js b/lib/utils/error-handler.js index b2fd45a5f..6631c1074 100644 --- a/lib/utils/error-handler.js +++ b/lib/utils/error-handler.js @@ -247,6 +247,6 @@ function writeLogFile () { log.record.length = 0 wroteLogFile = true } catch (ex) { - return + } } diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index cd31d7d71..126b440c8 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -299,7 +299,7 @@ function errorMessage (er) { ]) break } // else passthrough - /*eslint no-fallthrough:0*/ + /* eslint no-fallthrough:0 */ case 'ENOSPC': short.push(['nospc', er.message]) diff --git a/lib/utils/gunzip-maybe.js b/lib/utils/gunzip-maybe.js index db75f0601..adf7e4402 100644 --- a/lib/utils/gunzip-maybe.js +++ b/lib/utils/gunzip-maybe.js @@ -11,8 +11,8 @@ function gunzip () { var stream = duplex() var peeker = through(function (chunk, enc, cb) { var newStream = hasGzipHeader(chunk) - ? zlib.createGunzip() - : through() + ? zlib.createGunzip() + : through() stream.setReadable(newStream) stream.setWritable(newStream) stream.write(chunk) diff --git a/lib/utils/is-registry.js b/lib/utils/is-registry.js index 434cdbecb..e5f08e16a 100644 --- a/lib/utils/is-registry.js +++ b/lib/utils/is-registry.js @@ -9,4 +9,3 @@ function isRegistry (req) { if (req.type === 'range' || req.type === 'version' || req.type === 'tag') return true return false } - diff --git a/lib/utils/metrics-launch.js b/lib/utils/metrics-launch.js index 821f8bc7e..7e2a8d1cc 100644 --- a/lib/utils/metrics-launch.js +++ b/lib/utils/metrics-launch.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable camelcase */ module.exports = launchSendMetrics var fs = require('graceful-fs') var child_process = require('child_process') diff --git a/lib/utils/parse-json.js b/lib/utils/parse-json.js index c4149d282..c2ebac358 100644 --- a/lib/utils/parse-json.js +++ b/lib/utils/parse-json.js @@ -8,7 +8,7 @@ parseJSON.noExceptions = function (content) { try { return parseJSON(content) } catch (ex) { - return + } } diff --git a/lib/utils/perf.js b/lib/utils/perf.js index 042326322..eaef985fa 100644 --- a/lib/utils/perf.js +++ b/lib/utils/perf.js @@ -22,6 +22,5 @@ function timeEnd (name) { delete timings[name] } else { log.silly('timing', "Tried to end timer that doesn't exist:", name) - return } } diff --git a/lib/utils/pick-manifest-from-registry-metadata.js b/lib/utils/pick-manifest-from-registry-metadata.js index e2c0d2e5a..589cef207 100644 --- a/lib/utils/pick-manifest-from-registry-metadata.js +++ b/lib/utils/pick-manifest-from-registry-metadata.js @@ -21,6 +21,6 @@ function pickManifestFromRegistryMetadata (spec, tag, versions, metadata) { } else if (spec === '*' && versions.length && tagged && metadata.versions[tagged]) { return {resolvedTo: tag, manifest: metadata.versions[tagged]} } else { - return + } } diff --git a/lib/utils/read-user-info.js b/lib/utils/read-user-info.js index 359432cf7..81bb44c98 100644 --- a/lib/utils/read-user-info.js +++ b/lib/utils/read-user-info.js @@ -63,4 +63,3 @@ function readEmail (msg, email, opts, isRetry) { return read({prompt: msg, default: email || ''}) .then((username) => readEmail(msg, username, opts, true)) } - diff --git a/lib/version.js b/lib/version.js index 23880b61a..d73d2507e 100644 --- a/lib/version.js +++ b/lib/version.js @@ -323,8 +323,8 @@ function stagePackageFiles (localData, options) { function addLocalFile (file, options, ignoreFailure) { const p = git.exec(['add', path.join(npm.localPrefix, file)], options) return ignoreFailure - ? p.catch(() => {}) - : p + ? p.catch(() => {}) + : p } function write (data, file, indent, newline, cb) { @@ -334,7 +334,7 @@ function write (data, file, indent, newline, cb) { log.verbose('version.write', 'data', data, 'to', file) writeFileAtomic( path.join(npm.localPrefix, file), - new Buffer(stringifyPackage(data, indent, newline)), + stringifyPackage(data, indent, newline), cb ) } diff --git a/lib/view.js b/lib/view.js index edb600577..0070e2d40 100644 --- a/lib/view.js +++ b/lib/view.js @@ -171,8 +171,8 @@ function fetchAndRead (nv, args, silent, cb) { ) { data.version = version BB.all(results.map((v) => prettyView(data, v[Object.keys(v)[0]]['']))) - .nodeify(cb) - .then(() => retval) + .nodeify(cb) + .then(() => retval) } else { printData(retval, data._id, cb.bind(null, error, retval)) } @@ -471,8 +471,8 @@ function cleanup (data) { if (keys.length <= 3 && data.name && (keys.length === 1 || - keys.length === 3 && data.email && data.url || - keys.length === 2 && (data.email || data.url))) { + (keys.length === 3 && data.email && data.url) || + (keys.length === 2 && (data.email || data.url)))) { data = unparsePerson(data) } return data diff --git a/scripts/changelog.js b/scripts/changelog.js index 07c8eef94..ff6e43e38 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -29,7 +29,7 @@ function shortname (url) { } } -function print_commit (c) { +function printCommit (c) { console.log(`* [\`${c.shortid}\`](https://github.com/npm/npm/commit/${c.fullid})`) if (c.fixes) { let label = shortname(c.fixes) @@ -51,10 +51,10 @@ function print_commit (c) { .replace(/^[-a-z]+: /, '') .replace(/^/mg, ' ') .replace(/\n$/, '') - // backtickify package@version + // backtickify package@version .replace(/^(\s*[^@\s]+@\d+[.]\d+[.]\d+)(\s*\S)/g, '$1:$2') .replace(/\b([^@\s]+@\d+[.]\d+[.]\d+)\b/g, '`$1`') - // linkify commitids + // linkify commitids .replace(/\b([a-f0-9]{7,8})\b/g, '[`$1`](https://github.com/npm/npm/commit/$1)') .replace(/\b#(\d+)\b/g, '[#$1](https://github.com/npm/npm/issues/$1)') console.log(msg) @@ -71,9 +71,9 @@ function main () { let commit log.forEach(function (line) { let m - /*eslint no-cond-assign:0*/ + /* eslint no-cond-assign:0 */ if (/^---$/.test(line)) { - print_commit(commit) + printCommit(commit) } else if (m = line.match(/^([a-f0-9]{7,9}) ([a-f0-9]+) (?:[(]([^)]+)[)] )?(.*?) [(](.*?)[)]/)) { commit = { shortid: m[1], diff --git a/scripts/index-build.js b/scripts/index-build.js index 058bc7401..e782716d7 100755 --- a/scripts/index-build.js +++ b/scripts/index-build.js @@ -18,10 +18,10 @@ glob(root + '/{README.md,doc/*/*.md}', function (er, files) { return f }).sort(function (a, b) { return (a[0] === b[0]) - ? (path.basename(a[1]) === 'npm.md' ? -1 - : path.basename(b[1]) === 'npm.md' ? 1 - : a[1] > b[1] ? 1 : -1) - : a[0] - b[0] + ? (path.basename(a[1]) === 'npm.md' ? -1 + : path.basename(b[1]) === 'npm.md' ? 1 + : a[1] > b[1] ? 1 : -1) + : a[0] - b[0] })) }) diff --git a/scripts/maketest b/scripts/maketest index e3105b5c0..118eb5fbc 100755 --- a/scripts/maketest +++ b/scripts/maketest @@ -29,7 +29,6 @@ const Tacks = require('tacks') const File = Tacks.File const Symlink = Tacks.Symlink const Dir = Tacks.Dir -const extend = Object.assign || require('util')._extend const common = require('../common-tap.js') const basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -40,7 +39,7 @@ const tmpdir = path.join(basedir, 'tmp') const conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/broken-under-nyc-and-travis/lifecycle-path.js b/test/broken-under-nyc-and-travis/lifecycle-path.js index 5804eb59a..6209319b4 100644 --- a/test/broken-under-nyc-and-travis/lifecycle-path.js +++ b/test/broken-under-nyc-and-travis/lifecycle-path.js @@ -163,7 +163,7 @@ function checkPath (testconfig, t) { // get the ones we tacked on, then the system-specific requirements var expectedPaths = ['{{ROOT}}/node_modules/npm-lifecycle/node-gyp-bin', - '{{PKG}}/node_modules/.bin'] + '{{PKG}}/node_modules/.bin'] // Check that the behaviour matches the configuration that was actually // used by the child process, as the coverage tooling may set the diff --git a/test/common-tap.js b/test/common-tap.js index 16475411e..18a5174f5 100644 --- a/test/common-tap.js +++ b/test/common-tap.js @@ -1,8 +1,8 @@ 'use strict' +/* eslint-disable camelcase */ var fs = require('graceful-fs') var readCmdShim = require('read-cmd-shim') var isWindows = require('../lib/utils/is-windows.js') -var extend = Object.assign || require('util')._extend var Bluebird = require('bluebird') // cheesy hackaround for test deps (read: nock) that rely on setImmediate @@ -52,7 +52,7 @@ exports.npm = function (cmd, opts, cb) { } cb = once(cb) cmd = [bin].concat(cmd) - opts = extend({}, opts || {}) + opts = Object.assign({}, opts || {}) opts.env = opts.env || process.env if (opts.env._storage) opts.env = Object.assign({}, opts.env._storage) @@ -158,7 +158,7 @@ function Environment (env) { if (env instanceof Environment) return env.clone() Object.defineProperty(this, '_storage', { - value: extend({}, env) + value: Object.assign({}, env) }) } Environment.prototype = {} diff --git a/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js b/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js index 77463e8be..fadfc330f 100644 --- a/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js +++ b/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js @@ -88,7 +88,7 @@ test('add-remote-git#get-resolved edge cases', function (t) { 'git+ssh://user@bananaboat.com:galbi/blah.git#decadacefadabade', 'don\'t break non-hosted scp-style locations' ) -/* + /* t.equal( tryGetResolved('git+ssh://bananaboat:galbi/blah', 'decadacefadabade'), 'git+ssh://bananaboat:galbi/blah#decadacefadabade', diff --git a/test/need-npm5-update/belongs-in-pacote/git-races.js b/test/need-npm5-update/belongs-in-pacote/git-races.js index c6c27d504..60136125d 100644 --- a/test/need-npm5-update/belongs-in-pacote/git-races.js +++ b/test/need-npm5-update/belongs-in-pacote/git-races.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ var execFile = require('child_process').execFile var path = require('path') var zlib = require('zlib') diff --git a/test/need-npm5-update/legacy-npm-self-install.js b/test/need-npm5-update/legacy-npm-self-install.js index d9d1124bd..6bcd80736 100644 --- a/test/need-npm5-update/legacy-npm-self-install.js +++ b/test/need-npm5-update/legacy-npm-self-install.js @@ -9,7 +9,6 @@ var osenv = require('osenv') var npmpath = path.resolve(__dirname, '../..') var basepath = path.resolve(osenv.tmpdir(), path.basename(__filename, '.js')) var globalpath = path.resolve(basepath, 'global') -var extend = Object.assign || require('util')._extend var isWin32 = process.platform === 'win32' test('setup', function (t) { @@ -41,7 +40,7 @@ function exists () { test('npm-self-install', function (t) { if (!tarball) return t.done() - var env = extend({}, process.env) + var env = Object.assign({}, process.env) var pathsep = isWin32 ? ';' : ':' env.npm_config_prefix = globalpath env.npm_config_global = 'true' diff --git a/test/need-npm5-update/lifecycle-signal.js b/test/need-npm5-update/lifecycle-signal.js index c0fdb766c..a003fb54a 100644 --- a/test/need-npm5-update/lifecycle-signal.js +++ b/test/need-npm5-update/lifecycle-signal.js @@ -19,7 +19,7 @@ asyncScript += '});setInterval(function(){},10);' var zombieScript = 'console.error(process.pid);process.on(\'SIGINT\',function (){' zombieScript += '});setInterval(function(){console.error(process.pid)},10);' -var SIGSEGV = require('constants').SIGSEGV +var SIGSEGV = require('constants').SIGSEGV // eslint-disable-line node/no-deprecated-api var json = { name: 'lifecycle-signal', diff --git a/test/need-npm5-update/move-no-clobber-dest-node-modules.js b/test/need-npm5-update/move-no-clobber-dest-node-modules.js index 4e487837a..a00c72024 100644 --- a/test/need-npm5-update/move-no-clobber-dest-node-modules.js +++ b/test/need-npm5-update/move-no-clobber-dest-node-modules.js @@ -15,8 +15,8 @@ function File (contents) { return { type: 'file', contents: typeof contents === 'object' - ? JSON.stringify(contents) - : contents + ? JSON.stringify(contents) + : contents } } @@ -64,7 +64,7 @@ var fixtures = Dir({ version: '1.0.0' }) }), -// The local config + // The local config 'package.json': File({ dependencies: { moda: fixturepath('moda@1.0.1'), diff --git a/test/need-npm5-update/outdated-depth-integer.js b/test/need-npm5-update/outdated-depth-integer.js index 5e743a0a7..98c08fa19 100644 --- a/test/need-npm5-update/outdated-depth-integer.js +++ b/test/need-npm5-update/outdated-depth-integer.js @@ -45,8 +45,8 @@ test('outdated depth integer', function (t) { pkg, 'underscore', undefined, // no version installed - '1.3.1', // wanted - '1.5.1', // latest + '1.3.1', // wanted + '1.5.1', // latest '1.3.1', null ]] @@ -58,7 +58,7 @@ test('outdated depth integer', function (t) { registry: common.registry, depth: 5 } - , function () { + , function () { npm.install('request@0.9.0', function (er) { if (er) throw new Error(er) npm.outdated(function (err, d) { diff --git a/test/need-npm5-update/outdated-symlink.js b/test/need-npm5-update/outdated-symlink.js index a7792f4a3..2f74e0551 100644 --- a/test/need-npm5-update/outdated-symlink.js +++ b/test/need-npm5-update/outdated-symlink.js @@ -10,11 +10,10 @@ var common = require('../common-tap.js') var pkg = path.resolve(__dirname, 'outdated-symlink') var cache = path.resolve(pkg, 'cache') -var extend = Object.assign || require('util')._extend var fakeRoot = path.join(pkg, 'fakeRoot') var OPTS = { - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { 'npm_config_prefix': fakeRoot, 'registry': common.registry }) diff --git a/test/need-npm5-update/peer-deps-toplevel.js b/test/need-npm5-update/peer-deps-toplevel.js index e2285e769..137375a23 100644 --- a/test/need-npm5-update/peer-deps-toplevel.js +++ b/test/need-npm5-update/peer-deps-toplevel.js @@ -5,7 +5,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -16,7 +15,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/need-npm5-update/rm-linked.js b/test/need-npm5-update/rm-linked.js index 381d7bc67..9123b8760 100644 --- a/test/need-npm5-update/rm-linked.js +++ b/test/need-npm5-update/rm-linked.js @@ -27,7 +27,7 @@ var linkedJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, dependencies: { 'baz': '1.0.0' @@ -42,7 +42,7 @@ var linkedDepJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' @@ -54,7 +54,7 @@ var installJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, dependencies: { 'foo': '1.0.0' diff --git a/test/need-npm5-update/shrinkwrap-complete-except-dev.js b/test/need-npm5-update/shrinkwrap-complete-except-dev.js index 156721507..abafde0af 100644 --- a/test/need-npm5-update/shrinkwrap-complete-except-dev.js +++ b/test/need-npm5-update/shrinkwrap-complete-except-dev.js @@ -6,7 +6,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -22,7 +21,7 @@ var installedModuleD = path.join(appdir, 'node_modules', 'module-d') var conf = { cwd: appdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/network/git-cache-locking.js b/test/network/git-cache-locking.js index 29ab5709b..9c3e903be 100644 --- a/test/network/git-cache-locking.js +++ b/test/network/git-cache-locking.js @@ -6,7 +6,6 @@ var mkdirp = require('mkdirp') var pkg = path.resolve(__dirname, 'git-cache-locking') var tmp = path.join(pkg, 'tmp') var cache = path.join(pkg, 'cache') -var shallowClone = Object.assign || require('util')._extend test('setup', function (t) { rimraf.sync(pkg) @@ -18,7 +17,7 @@ test('git-cache-locking: install a git dependency', function (t) { // disable git integration tests on Travis. if (process.env.TRAVIS) return t.end() - var gitEnv = shallowClone({}, process.env) + var gitEnv = Object.assign({}, process.env) gitEnv.npm_config_cache = cache gitEnv.npm_config_tmp = tmp gitEnv.npm_config_prefix = pkg diff --git a/test/network/registry.js b/test/network/registry.js index d8ec4a204..3dbe23ffd 100644 --- a/test/network/registry.js +++ b/test/network/registry.js @@ -26,10 +26,8 @@ if (v[0] === 0 && v[1] < 10) { }) } -var extend = Object.assign || require('util')._extend - function runTests () { - var env = extend({ TAP: 1 }, process.env) + var env = Object.assign({ TAP: 1 }, process.env) env.npm = npmExec // TODO: fix tap and / or nyc to handle nested invocations properly env.COVERALLS_REPO_TOKEN = '' diff --git a/test/tap/adduser-always-auth.js b/test/tap/adduser-always-auth.js index c0f302eef..d327e35a9 100644 --- a/test/tap/adduser-always-auth.js +++ b/test/tap/adduser-always-auth.js @@ -33,7 +33,7 @@ function verifyStdout (runner, successMessage, t) { function mocks (server) { server.filteringRequestBody(function (r) { - if (r.match(/\"_id\":\"org\.couchdb\.user:u\"/)) { + if (r.match(/"_id":"org\.couchdb\.user:u"/)) { return 'auth' } else { return 'invalid' @@ -53,18 +53,18 @@ test('npm login', function (t) { '--loglevel', 'silent', '--userconfig', outfile ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, /:always-auth=false/, 'always-auth is scoped and false (by default)') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, /:always-auth=false/, 'always-auth is scoped and false (by default)') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) }) - }) var message = 'Logged in as u on ' + common.registry + '/.' runner.stdout.on('data', verifyStdout(runner, message, t)) @@ -83,36 +83,36 @@ test('npm login --scope <scope> uses <scope>:registry as its URI', function (t) scope + ':registry', uri ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') - mr({ port: port, plugin: mocks }, function (er, s) { - var runner = common.npm( - [ - 'login', - '--loglevel', 'silent', - '--userconfig', outfile, - '--scope', scope - ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, new RegExp(scope + ':registry=' + uri), 'scope:registry is set') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() - }) - }) + mr({ port: port, plugin: mocks }, function (er, s) { + var runner = common.npm( + [ + 'login', + '--loglevel', 'silent', + '--userconfig', outfile, + '--scope', scope + ], + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, new RegExp(scope + ':registry=' + uri), 'scope:registry is set') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) + }) - var message = 'Logged in as u to scope ' + scope + ' on ' + uri + '.' - runner.stdout.on('data', verifyStdout(runner, message, t)) + var message = 'Logged in as u to scope ' + scope + ' on ' + uri + '.' + runner.stdout.on('data', verifyStdout(runner, message, t)) + }) }) - }) }) test('npm login --scope <scope> makes sure <scope> is prefixed by an @', function (t) { @@ -128,36 +128,36 @@ test('npm login --scope <scope> makes sure <scope> is prefixed by an @', functio prefixedScope + ':registry', uri ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') - mr({ port: port, plugin: mocks }, function (er, s) { - var runner = common.npm( - [ - 'login', - '--loglevel', 'silent', - '--userconfig', outfile, - '--scope', scope - ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, new RegExp(prefixedScope + ':registry=' + uri), 'scope:registry is set') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() - }) - }) + mr({ port: port, plugin: mocks }, function (er, s) { + var runner = common.npm( + [ + 'login', + '--loglevel', 'silent', + '--userconfig', outfile, + '--scope', scope + ], + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, new RegExp(prefixedScope + ':registry=' + uri), 'scope:registry is set') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) + }) - var message = 'Logged in as u to scope ' + prefixedScope + ' on ' + uri + '.' - runner.stdout.on('data', verifyStdout(runner, message, t)) + var message = 'Logged in as u to scope ' + prefixedScope + ' on ' + uri + '.' + runner.stdout.on('data', verifyStdout(runner, message, t)) + }) }) - }) }) test('npm login --scope <scope> --registry <registry> uses <registry> as its URI', function (t) { @@ -170,37 +170,37 @@ test('npm login --scope <scope> --registry <registry> uses <registry> as its URI scope + ':registry', 'invalidurl' ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') - mr({ port: common.port, plugin: mocks }, function (er, s) { - var runner = common.npm( - [ - 'login', - '--registry', common.registry, - '--loglevel', 'silent', - '--userconfig', outfile, - '--scope', scope - ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, new RegExp(scope + ':registry=' + common.registry), 'scope:registry is set') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() - }) - }) + mr({ port: common.port, plugin: mocks }, function (er, s) { + var runner = common.npm( + [ + 'login', + '--registry', common.registry, + '--loglevel', 'silent', + '--userconfig', outfile, + '--scope', scope + ], + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, new RegExp(scope + ':registry=' + common.registry), 'scope:registry is set') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) + }) - var message = 'Logged in as u to scope ' + scope + ' on ' + common.registry + '/.' - runner.stdout.on('data', verifyStdout(runner, message, t)) + var message = 'Logged in as u to scope ' + scope + ' on ' + common.registry + '/.' + runner.stdout.on('data', verifyStdout(runner, message, t)) + }) }) - }) }) test('npm login --always-auth', function (t) { @@ -213,18 +213,18 @@ test('npm login --always-auth', function (t) { '--userconfig', outfile, '--always-auth' ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, /:always-auth=true/, 'always-auth is scoped and true') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, /:always-auth=true/, 'always-auth is scoped and true') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) }) - }) var message = 'Logged in as u on ' + common.registry + '/.' runner.stdout.on('data', verifyStdout(runner, message, t)) @@ -241,18 +241,18 @@ test('npm login --no-always-auth', function (t) { '--userconfig', outfile, '--no-always-auth' ], - opts, - function (err, code) { - t.notOk(code, 'exited OK') - t.notOk(err, 'no error output') - var config = fs.readFileSync(outfile, 'utf8') - t.like(config, /:always-auth=false/, 'always-auth is scoped and false') - s.close() - rimraf(outfile, function (err) { - t.ifError(err, 'removed config file OK') - t.end() + opts, + function (err, code) { + t.notOk(code, 'exited OK') + t.notOk(err, 'no error output') + var config = fs.readFileSync(outfile, 'utf8') + t.like(config, /:always-auth=false/, 'always-auth is scoped and false') + s.close() + rimraf(outfile, function (err) { + t.ifError(err, 'removed config file OK') + t.end() + }) }) - }) var message = 'Logged in as u on ' + common.registry + '/.' runner.stdout.on('data', verifyStdout(runner, message, t)) diff --git a/test/tap/adduser-legacy-auth.js b/test/tap/adduser-legacy-auth.js index 677d378d8..49015878f 100644 --- a/test/tap/adduser-legacy-auth.js +++ b/test/tap/adduser-legacy-auth.js @@ -11,7 +11,7 @@ var opts = { cwd: __dirname } var pkg = path.resolve(__dirname, 'adduser-legacy-auth') var outfile = path.resolve(pkg, '_npmrc') -var contents = '_auth=' + new Buffer('u:x').toString('base64') + '\n' + +var contents = '_auth=' + Buffer.from('u:x').toString('base64') + '\n' + 'registry=https://nonexistent.lvh.me/registry\n' + 'email=u@p.me\n' @@ -38,7 +38,7 @@ function mocks (server) { '/-/user/org.couchdb.user:u/-rev/3-deadcafebabebeef', 'auth', { authorization: 'Basic dTpw' } - ).reply(201, { username: 'u', password: 'p', email: 'u@p.me' }) + ).reply(201, { username: 'u', password: 'p', email: 'u@p.me' }) } test('setup', function (t) { diff --git a/test/tap/adduser-oauth.js b/test/tap/adduser-oauth.js index 20159bceb..00c7badaf 100644 --- a/test/tap/adduser-oauth.js +++ b/test/tap/adduser-oauth.js @@ -33,7 +33,7 @@ test('setup', function (t) { mkdirp.sync(pkg) fs.writeFileSync(configfile, '') var s = '#!/usr/bin/env bash\n' + - 'echo \"$@\" > ' + outfile + '\n' + 'echo "$@" > ' + outfile + '\n' fs.writeFileSync(fakeBrowser, s, 'ascii') fs.chmodSync(fakeBrowser, '0755') t.pass('made script') diff --git a/test/tap/adduser-saml.js b/test/tap/adduser-saml.js index a7941f6d6..377b1ecf4 100644 --- a/test/tap/adduser-saml.js +++ b/test/tap/adduser-saml.js @@ -33,7 +33,7 @@ test('setup', function (t) { mkdirp.sync(pkg) fs.writeFileSync(configfile, '') var s = '#!/usr/bin/env bash\n' + - 'echo \"$@\" > ' + outfile + '\n' + 'echo "$@" > ' + outfile + '\n' fs.writeFileSync(fakeBrowser, s, 'ascii') fs.chmodSync(fakeBrowser, '0755') t.pass('made script') diff --git a/test/tap/anon-cli-metrics.js b/test/tap/anon-cli-metrics.js index 2ece5a1e6..100ca526c 100644 --- a/test/tap/anon-cli-metrics.js +++ b/test/tap/anon-cli-metrics.js @@ -7,7 +7,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -19,7 +18,7 @@ var metricsFile = path.join(cachedir, 'anonymous-cli-metrics.json') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/auto-prune.js b/test/tap/auto-prune.js index 00d01675c..3fa5d5d05 100644 --- a/test/tap/auto-prune.js +++ b/test/tap/auto-prune.js @@ -5,7 +5,6 @@ const mr = require('npm-registry-mock') const Tacks = require('tacks') const File = Tacks.File const Dir = Tacks.Dir -const extend = Object.assign || require('util')._extend const common = require('../common-tap.js') const basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -16,7 +15,7 @@ const tmpdir = path.join(basedir, 'tmp') const conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/bugs.js b/test/tap/bugs.js index 8b992fd7b..4d2ee37e1 100644 --- a/test/tap/bugs.js +++ b/test/tap/bugs.js @@ -14,7 +14,7 @@ var opts = { cwd: __dirname } test('setup', function (t) { var s = '#!/usr/bin/env bash\n' + - 'echo \"$@\" > ' + JSON.stringify(__dirname) + '/_output\n' + 'echo "$@" > ' + JSON.stringify(__dirname) + '/_output\n' fs.writeFileSync(join(__dirname, '/_script.sh'), s, 'ascii') fs.chmodSync(join(__dirname, '/_script.sh'), '0755') t.pass('made script') diff --git a/test/tap/builtin-config.js b/test/tap/builtin-config.js index 22a447c9c..b960ed038 100644 --- a/test/tap/builtin-config.js +++ b/test/tap/builtin-config.js @@ -31,12 +31,12 @@ test('setup', function (t) { test('install npm into first folder', function (t) { t.plan(1) var args = ['install', npm, '-g', - '--prefix=' + folder + '/first', - '--ignore-scripts', - '--cache=' + folder + '/cache', - '--tmp=' + folder + '/tmp', - '--loglevel=warn', - '--progress'] + '--prefix=' + folder + '/first', + '--ignore-scripts', + '--cache=' + folder + '/cache', + '--tmp=' + folder + '/tmp', + '--loglevel=warn', + '--progress'] common.npm(args, {}, function (er, code) { if (er) throw er t.equal(code, 0) @@ -47,17 +47,17 @@ test('install npm into first folder', function (t) { test('write npmrc file', function (t) { t.plan(1) common.npm(['explore', 'npm', '-g', - '--prefix=' + folder + '/first', - '--cache=' + folder + '/cache', - '--tmp=' + folder + '/tmp', - '--', node, __filename, 'write-builtin', process.pid - ], - {'stdio': 'inherit'}, - function (er, code) { - if (er) throw er - t.equal(code, 0) - t.end() - }) + '--prefix=' + folder + '/first', + '--cache=' + folder + '/cache', + '--tmp=' + folder + '/tmp', + '--', node, __filename, 'write-builtin', process.pid + ], + {'stdio': 'inherit'}, + function (er, code) { + if (er) throw er + t.equal(code, 0) + t.end() + }) }) test('use first npm to install second npm', function (t) { @@ -91,11 +91,11 @@ test('use first npm to install second npm', function (t) { ], {} ) - .on('error', function (er) { throw er }) - .on('close', function (code) { - t.equal(code, 0, 'second npm install') - t.end() - }) + .on('error', function (er) { throw er }) + .on('close', function (code) { + t.equal(code, 0, 'second npm install') + t.end() + }) } ) }) @@ -103,31 +103,31 @@ test('use first npm to install second npm', function (t) { test('verify that the builtin config matches', function (t) { t.plan(3) common.npm([ 'root', '-g', - '--prefix=' + folder + '/first', - '--cache=' + folder + '/cache', - '--tmp=' + folder + '/tmp' - ], {}, - function (er, code, so) { - if (er) throw er - t.equal(code, 0) - var firstRoot = so.trim() - common.npm([ 'root', '-g', - '--prefix=' + folder + '/second', - '--cache=' + folder + '/cache', - '--tmp=' + folder + '/tmp' - ], {}, - function (er, code, so) { - if (er) throw er - t.equal(code, 0) - var secondRoot = so.trim() - var firstRc = path.resolve(firstRoot, 'npm', 'npmrc') - var secondRc = path.resolve(secondRoot, 'npm', 'npmrc') - var firstData = fs.readFileSync(firstRc, 'utf8').split(/\r?\n/) - var secondData = fs.readFileSync(secondRc, 'utf8').split(/\r?\n/) - t.isDeeply(firstData, secondData) - t.end() - }) - }) + '--prefix=' + folder + '/first', + '--cache=' + folder + '/cache', + '--tmp=' + folder + '/tmp' + ], {}, + function (er, code, so) { + if (er) throw er + t.equal(code, 0) + var firstRoot = so.trim() + common.npm([ 'root', '-g', + '--prefix=' + folder + '/second', + '--cache=' + folder + '/cache', + '--tmp=' + folder + '/tmp' + ], {}, + function (er, code, so) { + if (er) throw er + t.equal(code, 0) + var secondRoot = so.trim() + var firstRc = path.resolve(firstRoot, 'npm', 'npmrc') + var secondRc = path.resolve(secondRoot, 'npm', 'npmrc') + var firstData = fs.readFileSync(firstRc, 'utf8').split(/\r?\n/) + var secondData = fs.readFileSync(secondRc, 'utf8').split(/\r?\n/) + t.isDeeply(firstData, secondData) + t.end() + }) + }) }) test('clean', function (t) { diff --git a/test/tap/cache-add-unpublished.js b/test/tap/cache-add-unpublished.js index 0d39ad815..8966e43ae 100644 --- a/test/tap/cache-add-unpublished.js +++ b/test/tap/cache-add-unpublished.js @@ -29,7 +29,7 @@ test('cache add', function (t) { function setup (cb) { var s = require('http').createServer(function (req, res) { res.statusCode = 404 - res.end('{\"error\":\"not_found\"}\n') + res.end('{"error":"not_found"}\n') }) s.listen(1337, function () { cb(null, s) diff --git a/test/tap/ci.js b/test/tap/ci.js index 5a67b57e7..a523f8762 100644 --- a/test/tap/ci.js +++ b/test/tap/ci.js @@ -46,24 +46,24 @@ test('setup', () => { })) fixture.create(testDir) return mr({port: common.port}) - .then((server) => { - SERVER = server - return common.npm([ - 'install', - '--registry', common.registry - ], EXEC_OPTS) - .then(() => fs.readFileAsync( - path.join(testDir, 'package-lock.json'), - 'utf8') - ) - .then((lock) => { - RAW_LOCKFILE = lock - }) - .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) - .then((ret) => { - TREE = scrubFrom(JSON.parse(ret[1])) + .then((server) => { + SERVER = server + return common.npm([ + 'install', + '--registry', common.registry + ], EXEC_OPTS) + .then(() => fs.readFileAsync( + path.join(testDir, 'package-lock.json'), + 'utf8') + ) + .then((lock) => { + RAW_LOCKFILE = lock + }) + .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) + .then((ret) => { + TREE = scrubFrom(JSON.parse(ret[1])) + }) }) - }) }) test('basic installation', (t) => { @@ -72,65 +72,65 @@ test('basic installation', (t) => { 'package-lock.json': File(RAW_LOCKFILE) })) return rimraf(testDir) - .then(() => fixture.create(testDir)) - .then(() => common.npm([ - 'ci', - '--registry', common.registry, - '--loglevel', 'warn' - ], EXEC_OPTS)) - .then((ret) => { - const code = ret[0] - const stdout = ret[1] - const stderr = ret[2] - t.equal(code, 0, 'command completed without error') - t.equal(stdout.trim(), '', 'no output on stdout') - t.match( - stderr.trim(), - /^added 6 packages in \d+(?:\.\d+)?s$/, - 'no warnings on stderr, and final output has right number of packages' - ) - return fs.readdirAsync(path.join(testDir, 'node_modules')) - }) - .then((modules) => { - t.deepEqual(modules.sort(), [ - 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap' - ], 'packages installed') - return BB.all(modules.map((mod) => { - return fs.readFileAsync( - path.join(testDir, 'node_modules', mod, 'package.json') + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stdout = ret[1] + const stderr = ret[2] + t.equal(code, 0, 'command completed without error') + t.equal(stdout.trim(), '', 'no output on stdout') + t.match( + stderr.trim(), + /^added 6 packages in \d+(?:\.\d+)?s$/, + 'no warnings on stderr, and final output has right number of packages' ) - .then((f) => JSON.parse(f)) - .then((pkgjson) => { - t.equal(pkgjson.name, mod, `${mod} package name correct`) - t.match( - pkgjson._integrity, - /sha\d+-[a-z0-9=+/]+$/i, - `${mod} pkgjson has _integrity` - ) - t.match( - pkgjson._resolved, - new RegExp(`http.*/-/${mod}-${pkgjson.version}.tgz`), - `${mod} pkgjson has correct _resolved` - ) - t.match( - pkgjson._from, - new RegExp(`${mod}@.*`), - `${mod} pkgjson has _from field` + return fs.readdirAsync(path.join(testDir, 'node_modules')) + }) + .then((modules) => { + t.deepEqual(modules.sort(), [ + 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap' + ], 'packages installed') + return BB.all(modules.map((mod) => { + return fs.readFileAsync( + path.join(testDir, 'node_modules', mod, 'package.json') ) - }) - })) - }) - .then(() => fs.readFileAsync( - path.join(testDir, 'package-lock.json'), - 'utf8') - ) - .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged')) - .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) - .then((ret) => { - const lsResult = JSON.parse(ret[1]) - t.equal(ret[0], 0, 'ls exited successfully') - t.deepEqual(scrubFrom(lsResult), TREE, 'tree matches one from `install`') - }) + .then((f) => JSON.parse(f)) + .then((pkgjson) => { + t.equal(pkgjson.name, mod, `${mod} package name correct`) + t.match( + pkgjson._integrity, + /sha\d+-[a-z0-9=+/]+$/i, + `${mod} pkgjson has _integrity` + ) + t.match( + pkgjson._resolved, + new RegExp(`http.*/-/${mod}-${pkgjson.version}.tgz`), + `${mod} pkgjson has correct _resolved` + ) + t.match( + pkgjson._from, + new RegExp(`${mod}@.*`), + `${mod} pkgjson has _from field` + ) + }) + })) + }) + .then(() => fs.readFileAsync( + path.join(testDir, 'package-lock.json'), + 'utf8') + ) + .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged')) + .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) + .then((ret) => { + const lsResult = JSON.parse(ret[1]) + t.equal(ret[0], 0, 'ls exited successfully') + t.deepEqual(scrubFrom(lsResult), TREE, 'tree matches one from `install`') + }) }) test('supports npm-shrinkwrap.json as well', (t) => { @@ -139,43 +139,43 @@ test('supports npm-shrinkwrap.json as well', (t) => { 'npm-shrinkwrap.json': File(RAW_LOCKFILE) })) return rimraf(testDir) - .then(() => fixture.create(testDir)) - .then(() => common.npm([ - 'ci', - '--registry', common.registry, - '--loglevel', 'warn' - ], EXEC_OPTS)) - .then((ret) => { - const code = ret[0] - const stdout = ret[1] - const stderr = ret[2] - t.equal(code, 0, 'command completed without error') - t.equal(stdout.trim(), '', 'no output on stdout') - t.match( - stderr.trim(), - /^added 6 packages in \d+(?:\.\d+)?s$/, - 'no warnings on stderr, and final output has right number of packages' - ) - }) - .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) - .then((ret) => { - t.equal(ret[0], 0, 'ls exited successfully') - t.deepEqual( - scrubFrom(JSON.parse(ret[1])), - TREE, - 'tree matches one from `install`' + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stdout = ret[1] + const stderr = ret[2] + t.equal(code, 0, 'command completed without error') + t.equal(stdout.trim(), '', 'no output on stdout') + t.match( + stderr.trim(), + /^added 6 packages in \d+(?:\.\d+)?s$/, + 'no warnings on stderr, and final output has right number of packages' + ) + }) + .then(() => common.npm(['ls', '--json'], EXEC_OPTS)) + .then((ret) => { + t.equal(ret[0], 0, 'ls exited successfully') + t.deepEqual( + scrubFrom(JSON.parse(ret[1])), + TREE, + 'tree matches one from `install`' + ) + }) + .then(() => fs.readFileAsync( + path.join(testDir, 'npm-shrinkwrap.json'), + 'utf8') ) - }) - .then(() => fs.readFileAsync( - path.join(testDir, 'npm-shrinkwrap.json'), - 'utf8') - ) - .then((lock) => t.equal(lock, RAW_LOCKFILE, 'npm-shrinkwrap.json unchanged')) - .then(() => fs.readdirAsync(path.join(testDir))) - .then((files) => t.notOk( - files.some((f) => f === 'package-lock.json'), - 'no package-lock.json created' - )) + .then((lock) => t.equal(lock, RAW_LOCKFILE, 'npm-shrinkwrap.json unchanged')) + .then(() => fs.readdirAsync(path.join(testDir))) + .then((files) => t.notOk( + files.some((f) => f === 'package-lock.json'), + 'no package-lock.json created' + )) }) test('removes existing node_modules/ before installing', (t) => { @@ -189,37 +189,37 @@ test('removes existing node_modules/ before installing', (t) => { }) })) return rimraf(testDir) - .then(() => fixture.create(testDir)) - .then(() => common.npm([ - 'ci', - '--registry', common.registry, - '--loglevel', 'warn' - ], EXEC_OPTS)) - .then((ret) => { - const code = ret[0] - const stdout = ret[1] - const stderr = ret[2] - t.equal(code, 0, 'command completed without error') - t.equal(stdout.trim(), '', 'no output on stdout') - t.match( - stderr.trim(), - /^npm.*WARN.*removing existing node_modules/, - 'user warned that existing node_modules were removed' + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stdout = ret[1] + const stderr = ret[2] + t.equal(code, 0, 'command completed without error') + t.equal(stdout.trim(), '', 'no output on stdout') + t.match( + stderr.trim(), + /^npm.*WARN.*removing existing node_modules/, + 'user warned that existing node_modules were removed' + ) + return fs.readdirAsync(path.join(testDir, 'node_modules')) + }) + .then((modules) => { + t.deepEqual(modules.sort(), [ + 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap' + ], 'packages installed, with old node_modules dir gone') + }) + .then(() => common.npm(['ls'], EXEC_OPTS)) + .then((ret) => t.equal(ret[0], 0, 'ls exited successfully')) + .then(() => fs.readFileAsync( + path.join(testDir, 'package-lock.json'), + 'utf8') ) - return fs.readdirAsync(path.join(testDir, 'node_modules')) - }) - .then((modules) => { - t.deepEqual(modules.sort(), [ - 'async', 'checker', 'clean', 'minimist', 'optimist', 'wordwrap' - ], 'packages installed, with old node_modules dir gone') - }) - .then(() => common.npm(['ls'], EXEC_OPTS)) - .then((ret) => t.equal(ret[0], 0, 'ls exited successfully')) - .then(() => fs.readFileAsync( - path.join(testDir, 'package-lock.json'), - 'utf8') - ) - .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged')) + .then((lock) => t.equal(lock, RAW_LOCKFILE, 'package-lock.json unchanged')) }) test('installs all package types correctly') @@ -229,32 +229,32 @@ test('errors if package-lock.json missing', (t) => { 'package.json': File(PKG) })) return rimraf(testDir) - .then(() => fixture.create(testDir)) - .then(() => common.npm([ - 'ci', - '--registry', common.registry, - '--loglevel', 'warn' - ], EXEC_OPTS)) - .then((ret) => { - const code = ret[0] - const stdout = ret[1] - const stderr = ret[2] - t.equal(code, 1, 'command errored') - t.equal(stdout.trim(), '', 'no output on stdout') - t.match( - stderr.trim(), - /can only install packages with an existing package-lock/i, - 'user informed about the issue' - ) - return fs.readdirAsync(path.join(testDir)) - }) - .then((dir) => { - t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed') - t.notOk( - dir.some((f) => f === 'package-lock.json'), - 'no package-lock.json created' - ) - }) + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stdout = ret[1] + const stderr = ret[2] + t.equal(code, 1, 'command errored') + t.equal(stdout.trim(), '', 'no output on stdout') + t.match( + stderr.trim(), + /can only install packages with an existing package-lock/i, + 'user informed about the issue' + ) + return fs.readdirAsync(path.join(testDir)) + }) + .then((dir) => { + t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed') + t.notOk( + dir.some((f) => f === 'package-lock.json'), + 'no package-lock.json created' + ) + }) }) test('errors if package-lock.json invalid', (t) => { @@ -265,37 +265,37 @@ test('errors if package-lock.json invalid', (t) => { 'package-lock.json': File(badJson) })) return rimraf(testDir) - .then(() => fixture.create(testDir)) - .then(() => common.npm([ - 'ci', - '--registry', common.registry, - '--loglevel', 'warn' - ], EXEC_OPTS)) - .then((ret) => { - const code = ret[0] - const stdout = ret[1] - const stderr = ret[2] - t.equal(code, 1, 'command errored') - t.equal(stdout.trim(), '', 'no output on stdout') - t.match( - stderr.trim(), - /can only install packages when your package.json/i, - 'user informed about the issue' + .then(() => fixture.create(testDir)) + .then(() => common.npm([ + 'ci', + '--registry', common.registry, + '--loglevel', 'warn' + ], EXEC_OPTS)) + .then((ret) => { + const code = ret[0] + const stdout = ret[1] + const stderr = ret[2] + t.equal(code, 1, 'command errored') + t.equal(stdout.trim(), '', 'no output on stdout') + t.match( + stderr.trim(), + /can only install packages when your package.json/i, + 'user informed about the issue' + ) + return fs.readdirAsync(path.join(testDir)) + }) + .then((dir) => { + t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed') + }) + .then(() => fs.readFileAsync( + path.join(testDir, 'package-lock.json'), + 'utf8') + ) + .then((lock) => t.deepEqual( + JSON.parse(lock), + badJson, + 'bad package-lock.json left unchanged') ) - return fs.readdirAsync(path.join(testDir)) - }) - .then((dir) => { - t.notOk(dir.some((f) => f === 'node_modules'), 'no node_modules installed') - }) - .then(() => fs.readFileAsync( - path.join(testDir, 'package-lock.json'), - 'utf8') - ) - .then((lock) => t.deepEqual( - JSON.parse(lock), - badJson, - 'bad package-lock.json left unchanged') - ) }) test('cleanup', () => { diff --git a/test/tap/config-envReplace.js b/test/tap/config-envReplace.js index edec9e40d..0b4f628d6 100644 --- a/test/tap/config-envReplace.js +++ b/test/tap/config-envReplace.js @@ -1,3 +1,5 @@ +/* eslint-disable no-template-curly-in-string */ + const fs = require('fs') const mkdirp = require('mkdirp') const rimraf = require('rimraf') diff --git a/test/tap/config-meta.js b/test/tap/config-meta.js index f667077a1..527487f20 100644 --- a/test/tap/config-meta.js +++ b/test/tap/config-meta.js @@ -64,7 +64,7 @@ test('get lines', function (t) { var literal = m.match(/^[''].+?['']/) if (literal) { m = literal[0].slice(1, -1) - if (!m.match(/^\_/) && m !== 'argv') { + if (!m.match(/^_/) && m !== 'argv') { CONFS[m] = { file: f, line: i @@ -117,14 +117,14 @@ test('check configs', function (t) { } types.forEach(function (c) { - if (!c.match(/^\_/) && c !== 'argv' && !c.match(/^versions?$/) && c !== 'ham-it-up') { + if (!c.match(/^_/) && c !== 'argv' && !c.match(/^versions?$/) && c !== 'ham-it-up') { t.ok(DOC[c], 'defined type should be documented ' + c) t.ok(CONFS[c], 'defined type should be used ' + c) } }) defaults.forEach(function (c) { - if (!c.match(/^\_/) && c !== 'argv' && !c.match(/^versions?$/) && c !== 'ham-it-up') { + if (!c.match(/^_/) && c !== 'argv' && !c.match(/^versions?$/) && c !== 'ham-it-up') { t.ok(DOC[c], 'defaulted type should be documented ' + c) t.ok(CONFS[c], 'defaulted type should be used ' + c) } diff --git a/test/tap/correct-mkdir.js b/test/tap/correct-mkdir.js index a4f865987..2c93f943a 100644 --- a/test/tap/correct-mkdir.js +++ b/test/tap/correct-mkdir.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ var test = require('tap').test var assert = require('assert') var path = require('path') @@ -71,7 +72,7 @@ test('correct-mkdir: ignore ENOENTs from chownr', function (t) { } } var mock_chownr = function (path, uid, gid, cb) { - cb({code: 'ENOENT'}) + cb(Object.assign(new Error(), {code: 'ENOENT'})) } var mocks = { 'graceful-fs': mock_fs, @@ -147,7 +148,7 @@ test('correct-mkdir: SUDO_UID and SUDO_GID Windows', function (t) { } var mock_chownr = function (path, uid, gid, cb) { t.fail('chownr should not be called at all on Windows') - cb('nope') + cb(new Error('nope')) } var mocks = { 'graceful-fs': mock_fs, diff --git a/test/tap/debug-logs.js b/test/tap/debug-logs.js index e2dfb6a8b..a69973526 100644 --- a/test/tap/debug-logs.js +++ b/test/tap/debug-logs.js @@ -6,7 +6,6 @@ var glob = require('glob') var asyncMap = require('slide').asyncMap var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -17,7 +16,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, @@ -99,4 +98,3 @@ test('cleanup', function (t) { cleanup() t.done() }) - diff --git a/test/tap/dist-tag.js b/test/tap/dist-tag.js index 62ecab2c0..651639f32 100644 --- a/test/tap/dist-tag.js +++ b/test/tap/dist-tag.js @@ -27,7 +27,7 @@ function mocks (server) { // add c server.get('/-/package/@scoped%2fanother/dist-tags') .reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' }) - server.put('/-/package/@scoped%2fanother/dist-tags/c', '\"7.7.7\"') + server.put('/-/package/@scoped%2fanother/dist-tags/c', '"7.7.7"') .reply(200, { latest: '7.7.7', a: '0.0.2', b: '0.6.0', c: '7.7.7' }) // set same version diff --git a/test/tap/doctor.js b/test/tap/doctor.js index fa1a5fad1..26c74833e 100644 --- a/test/tap/doctor.js +++ b/test/tap/doctor.js @@ -1,5 +1,5 @@ 'use strict' - +/* eslint-disable camelcase */ const common = require('../common-tap.js') const http = require('http') const mr = require('npm-registry-mock') diff --git a/test/tap/gently-rm-cmdshims.js b/test/tap/gently-rm-cmdshims.js index ea1f47a0d..304c6956b 100644 --- a/test/tap/gently-rm-cmdshims.js +++ b/test/tap/gently-rm-cmdshims.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable camelcase */ var path = require('path') var fs = require('graceful-fs') var test = require('tap').test @@ -127,30 +128,30 @@ test('remove-cmd-shims', function (t) { var gentlyRm = require('../../lib/utils/gently-rm.js') runAll([ [gentlyRm, doremove_example_cmd, true, doremove_module], - [gentlyRm, doremove_example_cygwin, true, doremove_module] ], - function () { - fs.stat(doremove_example_cmd, function (er) { - t.is(er && er.code, 'ENOENT', 'cmd-shim was removed') - }) - fs.stat(doremove_example_cygwin, function (er) { - t.is(er && er.code, 'ENOENT', 'cmd-shim cygwin script was removed') - }) - }) + [gentlyRm, doremove_example_cygwin, true, doremove_module] ], + function () { + fs.stat(doremove_example_cmd, function (er) { + t.is(er && er.code, 'ENOENT', 'cmd-shim was removed') + }) + fs.stat(doremove_example_cygwin, function (er) { + t.is(er && er.code, 'ENOENT', 'cmd-shim cygwin script was removed') + }) + }) }) test('dont-remove-cmd-shims', function (t) { t.plan(2) var gentlyRm = require('../../lib/utils/gently-rm.js') runAll([ [gentlyRm, dontremove_example_cmd, true, dontremove_module], - [gentlyRm, dontremove_example_cygwin, true, dontremove_module] ], - function () { - fs.stat(dontremove_example_cmd, function (er) { - t.is(er, null, 'cmd-shim was not removed') - }) - fs.stat(dontremove_example_cygwin, function (er) { - t.is(er, null, 'cmd-shim cygwin script was not removed') - }) - }) + [gentlyRm, dontremove_example_cygwin, true, dontremove_module] ], + function () { + fs.stat(dontremove_example_cmd, function (er) { + t.is(er, null, 'cmd-shim was not removed') + }) + fs.stat(dontremove_example_cygwin, function (er) { + t.is(er, null, 'cmd-shim cygwin script was not removed') + }) + }) }) test('cleanup', function (t) { diff --git a/test/tap/gently-rm-linked-module.js b/test/tap/gently-rm-linked-module.js index a9804cd79..877c683c9 100644 --- a/test/tap/gently-rm-linked-module.js +++ b/test/tap/gently-rm-linked-module.js @@ -9,7 +9,6 @@ var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir var Symlink = Tacks.Symlink -var extend = Object.assign || require('util')._extend var isWindows = require('../../lib/utils/is-windows.js') var base = resolve(__dirname, basename(__filename, '.js')) @@ -35,7 +34,7 @@ var workingDir = resolve(base, 'working-dir') var toInstall = resolve(base, 'test-module') var linkedGlobal = resolve(base, 'linked-global-dir') -var env = extend({}, process.env) +var env = Object.assign({}, process.env) // We set the global install location via env var here // instead of passing it in via `--prefix` because diff --git a/test/tap/git-npmignore.js b/test/tap/git-npmignore.js index 1fe2ca24e..19d014c3d 100644 --- a/test/tap/git-npmignore.js +++ b/test/tap/git-npmignore.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ var child_process = require('child_process') var readdir = require('graceful-fs').readdirSync var path = require('path') diff --git a/test/tap/init-interrupt.js b/test/tap/init-interrupt.js index 799ff0716..b0c7643dd 100644 --- a/test/tap/init-interrupt.js +++ b/test/tap/init-interrupt.js @@ -1,3 +1,4 @@ +/* eslint-disable standard/no-callback-literal */ // if 'npm init' is interrupted with ^C, don't report // 'init written successfully' var test = require('tap').test diff --git a/test/tap/install-duplicate-deps-warning.js b/test/tap/install-duplicate-deps-warning.js index 9206fe253..017a5cdfe 100644 --- a/test/tap/install-duplicate-deps-warning.js +++ b/test/tap/install-duplicate-deps-warning.js @@ -8,7 +8,7 @@ var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') +var npm = require('../../') var pkg = path.resolve(__dirname, path.basename(__filename, '.js')) diff --git a/test/tap/install-order.js b/test/tap/install-order.js index 80b3f6f45..c4a2b1c38 100644 --- a/test/tap/install-order.js +++ b/test/tap/install-order.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable no-use-before-define */ var test = require('tap').test var sortActions = require('../../lib/install/diff-trees.js').sortActions var top = { diff --git a/test/tap/install-package-lock-only.js b/test/tap/install-package-lock-only.js index b117dc97e..9d8aa8dbe 100644 --- a/test/tap/install-package-lock-only.js +++ b/test/tap/install-package-lock-only.js @@ -6,7 +6,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -20,7 +19,7 @@ var nodeModulesPath = path.join(testdir, 'node_modules') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/install-parse-error.js b/test/tap/install-parse-error.js index 72d19efc2..b142abb39 100644 --- a/test/tap/install-parse-error.js +++ b/test/tap/install-parse-error.js @@ -49,4 +49,3 @@ test('cleanup', function (t) { cleanup() t.end() }) - diff --git a/test/tap/install-scoped-with-bundled-dependency.js b/test/tap/install-scoped-with-bundled-dependency.js index 7a620dfdc..bd197ae03 100644 --- a/test/tap/install-scoped-with-bundled-dependency.js +++ b/test/tap/install-scoped-with-bundled-dependency.js @@ -4,7 +4,6 @@ var test = require('tap').test var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -15,7 +14,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend({ + env: Object.assign({ npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/install-with-dev-dep-duplicate.js b/test/tap/install-with-dev-dep-duplicate.js index 41eb82331..2d31b8fad 100644 --- a/test/tap/install-with-dev-dep-duplicate.js +++ b/test/tap/install-with-dev-dep-duplicate.js @@ -8,7 +8,7 @@ var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') +var npm = require('../../') var pkg = path.resolve(__dirname, 'dev-dep-duplicate') diff --git a/test/tap/invalid-dep-version-filtering.js b/test/tap/invalid-dep-version-filtering.js index a4a872f54..19ab5d209 100644 --- a/test/tap/invalid-dep-version-filtering.js +++ b/test/tap/invalid-dep-version-filtering.js @@ -14,7 +14,7 @@ var fixture = new Tacks(Dir({ cache: Dir(), node_modules: Dir(), tarballs: Dir({ - 'pkgA.tgz': File(new Buffer( + 'pkgA.tgz': File(Buffer.from( '1f8b0800000000000003edcfcf0a0221100670cf3ec5e0396cfcb703bd8d' + '842cb5e4ca5a5da2776f5da153b78408fc5d3e6684e133f9e3e4c7b04f35' + 'e539cf9135868883b5509206b725ea3a6f9c01a634598d8e48134365d0e0' + @@ -23,7 +23,7 @@ var fixture = new Tacks(Dir({ '0000', 'hex' )), - 'pkgB1.tgz': File(new Buffer( + 'pkgB1.tgz': File(Buffer.from( '1f8b0800000000000003edcfc10a0221140550d77ec5c375d8d3d111fa1b' + '0b196ac891b16913fd7be308adda2544f0cee6e25d3caec99f463f847daa' + '292f798aac3144ec8d8192aeb75ba2aeef8ded8029ed8c46eb1c1a86aa43' + diff --git a/test/tap/is-fs-access-available.js b/test/tap/is-fs-access-available.js index 3c1b30ed0..2e5c7edc9 100644 --- a/test/tap/is-fs-access-available.js +++ b/test/tap/is-fs-access-available.js @@ -3,13 +3,12 @@ var fs = require('fs') var test = require('tap').test var requireInject = require('require-inject') var semver = require('semver') -var extend = Object.assign || require('util')._extend var globalProcess = global.process function loadIsFsAccessAvailable (newProcess, newFs) { - global.process = extend(extend({}, global.process), newProcess) - var mocks = {fs: extend(extend({}, fs), newFs)} + global.process = Object.assign({}, global.process, newProcess) + var mocks = {fs: Object.assign({}, fs, newFs)} var isFsAccessAvailable = requireInject('../../lib/install/is-fs-access-available.js', mocks) global.process = globalProcess return isFsAccessAvailable diff --git a/test/tap/link.js b/test/tap/link.js index 8a4275e19..88f3caed7 100644 --- a/test/tap/link.js +++ b/test/tap/link.js @@ -29,7 +29,7 @@ var readJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' @@ -41,7 +41,7 @@ var readScopedJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' @@ -53,7 +53,7 @@ var installJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' @@ -65,7 +65,7 @@ var insideInstallJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' diff --git a/test/tap/lockfile-http-deps.js b/test/tap/lockfile-http-deps.js index 860d40577..a614daf13 100644 --- a/test/tap/lockfile-http-deps.js +++ b/test/tap/lockfile-http-deps.js @@ -6,7 +6,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -17,7 +16,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, @@ -89,4 +88,3 @@ test('cleanup', function (t) { cleanup() t.done() }) - diff --git a/test/tap/map-to-registry.js b/test/tap/map-to-registry.js index d9677bd7e..f6fdef5f1 100644 --- a/test/tap/map-to-registry.js +++ b/test/tap/map-to-registry.js @@ -6,7 +6,7 @@ var mapRegistry = require('../../lib/utils/map-to-registry.js') var creds = { '//registry.npmjs.org/:username': 'u', - '//registry.npmjs.org/:_password': new Buffer('p').toString('base64'), + '//registry.npmjs.org/:_password': Buffer.from('p').toString('base64'), '//registry.npmjs.org/:email': 'e', cache: common.npm_config_cache } diff --git a/test/tap/nerf-dart.js b/test/tap/nerf-dart.js index a6df7272c..d205e527c 100644 --- a/test/tap/nerf-dart.js +++ b/test/tap/nerf-dart.js @@ -20,13 +20,13 @@ validNerfDart('http://registry.npmjs.org/some-package#random-hash') validNerfDart( 'http://relative.couchapp.npm/design/-/rewrite/', - '//relative.couchapp.npm/design/-/rewrite/' + '//relative.couchapp.npm/design/-/rewrite/' ) validNerfDart( 'http://relative.couchapp.npm:8080/design/-/rewrite/', - '//relative.couchapp.npm:8080/design/-/rewrite/' + '//relative.couchapp.npm:8080/design/-/rewrite/' ) validNerfDart( 'http://relative.couchapp.npm:8080/design/-/rewrite/some-package', - '//relative.couchapp.npm:8080/design/-/rewrite/' + '//relative.couchapp.npm:8080/design/-/rewrite/' ) diff --git a/test/tap/no-global-warns.js b/test/tap/no-global-warns.js index 577b39312..304cf5bf5 100644 --- a/test/tap/no-global-warns.js +++ b/test/tap/no-global-warns.js @@ -31,7 +31,7 @@ var installJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, author: '', license: 'ISC' diff --git a/test/tap/optional-metadep-rollback-collision.js b/test/tap/optional-metadep-rollback-collision.js index f4ac6bdc7..1c05d1ba5 100644 --- a/test/tap/optional-metadep-rollback-collision.js +++ b/test/tap/optional-metadep-rollback-collision.js @@ -1,4 +1,5 @@ 'use strict' +/* eslint-disable camelcase */ var fs = require('graceful-fs') var path = require('path') @@ -177,11 +178,11 @@ test('go go test racer', function (t) { }, stdio: 'pipe' }).spread((code, stdout, stderr) => { - t.comment(stdout.trim()) - t.comment(stderr.trim()) - t.is(code, 0, 'npm install exited with code 0') - t.notOk(/not ok/.test(stdout), 'should not contain the string \'not ok\'') - }) + t.comment(stdout.trim()) + t.comment(stderr.trim()) + t.is(code, 0, 'npm install exited with code 0') + t.notOk(/not ok/.test(stdout), 'should not contain the string \'not ok\'') + }) }) test('verify results', function (t) { diff --git a/test/tap/outdated-color.js b/test/tap/outdated-color.js index 7fc8c521e..3a81d05a8 100644 --- a/test/tap/outdated-color.js +++ b/test/tap/outdated-color.js @@ -54,14 +54,14 @@ test('does not use ansi styling', function (t) { '--registry', common.registry, 'outdated', 'underscore' ], - EXEC_OPTS, - function (err, code, stdout) { - t.ifError(err) - t.is(code, 1, 'npm outdated exited with code 1') - t.ok(stdout, stdout.length) - t.ok(!hasControlCodes(stdout)) - s.close() - }) + EXEC_OPTS, + function (err, code, stdout) { + t.ifError(err) + t.is(code, 1, 'npm outdated exited with code 1') + t.ok(stdout, stdout.length) + t.ok(!hasControlCodes(stdout)) + s.close() + }) }) }) diff --git a/test/tap/outdated-latest.js b/test/tap/outdated-latest.js index f5b0b307b..d72fd8717 100644 --- a/test/tap/outdated-latest.js +++ b/test/tap/outdated-latest.js @@ -5,7 +5,6 @@ const mr = require('npm-registry-mock') const Tacks = require('tacks') const File = Tacks.File const Dir = Tacks.Dir -const extend = Object.assign || require('util')._extend const common = require('../common-tap.js') const basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -16,7 +15,7 @@ const tmpdir = path.join(basedir, 'tmp') const conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/pack.js b/test/tap/pack.js index 06504ac47..a37b90fbb 100644 --- a/test/tap/pack.js +++ b/test/tap/pack.js @@ -20,88 +20,88 @@ const data = { function setup (dir) { return rimraf(dir) - .then(() => mkdirp(dir)) - .then(() => fs.writeFileAsync( - path.join(dir, 'package.json'), - JSON.stringify(data, null, 2)) - ) + .then(() => mkdirp(dir)) + .then(() => fs.writeFileAsync( + path.join(dir, 'package.json'), + JSON.stringify(data, null, 2)) + ) } test('basic pack', (t) => { return setup(testDir) - .then(() => common.npm([ - 'pack', - '--loglevel', 'notice', - '--cache', cache, - '--tmp', tmp, - '--prefix', testDir, - '--no-global' - ], { - cwd: testDir - })) - .spread((code, stdout, stderr) => { - t.equal(code, 0, 'npm pack exited ok') - t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json') - t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg') - return fs.statAsync( - path.join(testDir, 'generic-package-90000.100001.5.tgz') - ) - }) - .then((stat) => t.ok(stat, 'tarball written to cwd')) - .then(() => cleanup(testDir)) + .then(() => common.npm([ + 'pack', + '--loglevel', 'notice', + '--cache', cache, + '--tmp', tmp, + '--prefix', testDir, + '--no-global' + ], { + cwd: testDir + })) + .spread((code, stdout, stderr) => { + t.equal(code, 0, 'npm pack exited ok') + t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json') + t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg') + return fs.statAsync( + path.join(testDir, 'generic-package-90000.100001.5.tgz') + ) + }) + .then((stat) => t.ok(stat, 'tarball written to cwd')) + .then(() => cleanup(testDir)) }) test('pack --dry-run', (t) => { return setup(testDir) - .then(() => common.npm([ - 'pack', - '--dry-run', - '--loglevel', 'notice', - '--cache', cache, - '--tmp', tmp, - '--prefix', testDir, - '--no-global' - ], { - cwd: testDir - })) - .spread((code, stdout, stderr) => { - t.equal(code, 0, 'npm pack exited ok') - t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg') - return fs.statAsync( - path.join(testDir, 'generic-package-90000.100001.5.tgz') - ) - .then( - () => { throw new Error('should have failed') }, - (err) => t.equal(err.code, 'ENOENT', 'no tarball written!') - ) - }) - .then(() => cleanup(testDir)) + .then(() => common.npm([ + 'pack', + '--dry-run', + '--loglevel', 'notice', + '--cache', cache, + '--tmp', tmp, + '--prefix', testDir, + '--no-global' + ], { + cwd: testDir + })) + .spread((code, stdout, stderr) => { + t.equal(code, 0, 'npm pack exited ok') + t.match(stdout, /generic-package-90000\.100001\.5\.tgz/ig, 'found pkg') + return fs.statAsync( + path.join(testDir, 'generic-package-90000.100001.5.tgz') + ) + .then( + () => { throw new Error('should have failed') }, + (err) => t.equal(err.code, 'ENOENT', 'no tarball written!') + ) + }) + .then(() => cleanup(testDir)) }) test('pack --json', (t) => { return setup(testDir) - .then(() => common.npm([ - 'pack', - '--dry-run', - '--json', - '--loglevel', 'notice', - '--cache', cache, - '--tmp', tmp, - '--prefix', testDir, - '--no-global' - ], { - cwd: testDir - })) - .spread((code, stdout, stderr) => { - t.equal(code, 0, 'npm pack exited ok') - t.equal(stderr.trim(), '', 'no notice output') - t.similar(JSON.parse(stdout), [{ - filename: 'generic-package-90000.100001.5.tgz', - files: [{path: 'package.json'}], - entryCount: 1 - }], 'pack details output as valid json') - }) - .then(() => cleanup(testDir)) + .then(() => common.npm([ + 'pack', + '--dry-run', + '--json', + '--loglevel', 'notice', + '--cache', cache, + '--tmp', tmp, + '--prefix', testDir, + '--no-global' + ], { + cwd: testDir + })) + .spread((code, stdout, stderr) => { + t.equal(code, 0, 'npm pack exited ok') + t.equal(stderr.trim(), '', 'no notice output') + t.similar(JSON.parse(stdout), [{ + filename: 'generic-package-90000.100001.5.tgz', + files: [{path: 'package.json'}], + entryCount: 1 + }], 'pack details output as valid json') + }) + .then(() => cleanup(testDir)) }) function cleanup (dir) { return rimraf(dir) diff --git a/test/tap/peer-deps.js b/test/tap/peer-deps.js index c319c32e4..b516818da 100644 --- a/test/tap/peer-deps.js +++ b/test/tap/peer-deps.js @@ -8,7 +8,7 @@ var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') +var npm = require('../../') var pkg = path.resolve(__dirname, 'peer-deps') diff --git a/test/tap/prepublish-only.js b/test/tap/prepublish-only.js index 3681c7689..835da39a4 100644 --- a/test/tap/prepublish-only.js +++ b/test/tap/prepublish-only.js @@ -93,8 +93,8 @@ test('setup', function (t) { test('test', function (t) { server.filteringRequestBody(function () { return true }) - .put('/npm-test-prepublish-only', true) - .reply(201, {ok: true}) + .put('/npm-test-prepublish-only', true) + .reply(201, {ok: true}) common.npm( [ diff --git a/test/tap/prune-dev-dep-with-bins.js b/test/tap/prune-dev-dep-with-bins.js index a89db389d..686b5d8d6 100644 --- a/test/tap/prune-dev-dep-with-bins.js +++ b/test/tap/prune-dev-dep-with-bins.js @@ -50,7 +50,7 @@ var fixture = new Tacks( ') ELSE (\n' + '@SETLOCAL\n' + '@SET PATHEXT=%PATHEXT:;.JS;=;%\n' + - 'node "%~dp0\..\yes\yes.js" %*') + 'node "%~dp0\\..\\yes\\yes.js" %*') }) }), 'package.json': File({ @@ -102,4 +102,3 @@ test('cleanup', function (t) { cleanup() t.end() }) - diff --git a/test/tap/publish-config.js b/test/tap/publish-config.js index fb430af21..0566795db 100644 --- a/test/tap/publish-config.js +++ b/test/tap/publish-config.js @@ -19,7 +19,7 @@ fs.writeFileSync(pkg + '/package.json', JSON.stringify({ fs.writeFileSync(pkg + '/fixture_npmrc', '//localhost:1337/:email = fancy@feast.net\n' + '//localhost:1337/:username = fancy\n' + - '//localhost:1337/:_password = ' + new Buffer('feast').toString('base64')) + '//localhost:1337/:_password = ' + Buffer.from('feast').toString('base64')) test(function (t) { let child diff --git a/test/tap/publish-scoped.js b/test/tap/publish-scoped.js index c2a8301b7..b8fe0ae2f 100644 --- a/test/tap/publish-scoped.js +++ b/test/tap/publish-scoped.js @@ -35,15 +35,15 @@ test('setup', function (t) { test('npm publish should honor scoping', function (t) { server.filteringRequestBody(verify) - .put('/@bigco%2fpublish-organized', true) - .reply(201, {ok: true}) + .put('/@bigco%2fpublish-organized', true) + .reply(201, {ok: true}) var configuration = [ 'progress=false', 'cache=' + path.join(pkg, 'cache'), 'registry=http://nonexistent.lvh.me', '//localhost:1337/:username=username', - '//localhost:1337/:_password=' + new Buffer('password').toString('base64'), + '//localhost:1337/:_password=' + Buffer.from('password').toString('base64'), '//localhost:1337/:email=' + 'ogd@aoaioxxysz.net', '@bigco:registry=' + common.registry ] diff --git a/test/tap/publish.js b/test/tap/publish.js index 8dd17e591..765cfb07c 100644 --- a/test/tap/publish.js +++ b/test/tap/publish.js @@ -35,19 +35,19 @@ function setup () { let port = common.port function withServer (cb) { return mr({port: port++, throwOnUnmatched: true}) - .tap(cb) - .then((server) => { - server.done() - return server.close() - }) + .tap(cb) + .then((server) => { + server.done() + return server.close() + }) } test('basic npm publish', (t) => { setup() return withServer((server) => { server.filteringRequestBody(verify) - .put('/publish-organized', true) - .reply(201, {ok: true}) + .put('/publish-organized', true) + .reply(201, {ok: true}) return common.npm([ 'publish', @@ -55,14 +55,14 @@ test('basic npm publish', (t) => { '--cache', path.join(testDir, 'cache'), '--registry=' + common.registry.replace(common.port, server.port), `--//localhost:${server.port}/:username=username`, - `--//localhost:${server.port}/:_password=` + new Buffer('password').toString('base64'), + `--//localhost:${server.port}/:_password=` + Buffer.from('password').toString('base64'), `--//localhost:${server.port}/:email=` + 'ogd@aoaioxxysz.net' ], {'cwd': testDir}) - .spread((code, stdout, stderr) => { - t.comment(stdout) - t.comment(stderr) - t.is(code, 0, 'published without error') - }) + .spread((code, stdout, stderr) => { + t.comment(stdout) + t.comment(stderr) + t.is(code, 0, 'published without error') + }) function verify (body) { t.doesNotThrow(() => { @@ -96,27 +96,56 @@ test('npm publish --dry-run', (t) => { '--loglevel=notice', '--no-color' ], {'cwd': testDir}) - .spread((code, stdout, stderr) => { - t.comment(stdout) - t.comment(stderr) - t.is(code, 0, 'published without error') - t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json') - t.match(stderr, /notice\s+\d+[a-z]+\s+index\.js/gi, 'mentions index.js') - }) + .spread((code, stdout, stderr) => { + t.comment(stdout) + t.comment(stderr) + t.is(code, 0, 'published without error') + t.match(stderr, /notice\s+\d+[a-z]+\s+package\.json/gi, 'mentions package.json') + t.match(stderr, /notice\s+\d+[a-z]+\s+index\.js/gi, 'mentions index.js') + }) }) test('npm publish --json', (t) => { setup() return withServer((server) => { server.filteringRequestBody(() => true) - .put('/publish-organized', true) - .reply(201, {ok: true}) + .put('/publish-organized', true) + .reply(201, {ok: true}) return common.npm([ 'publish', '--json', '--registry', common.registry.replace(common.port, server.port), '--cache', path.join(testDir, 'cache') ], {'cwd': testDir}) + .spread((code, stdout, stderr) => { + t.comment(stdout) + t.comment(stderr) + t.is(code, 0, 'published without error') + t.similar(JSON.parse(stdout), { + name: 'publish-organized', + version: '1.2.5', + files: [ + {path: 'package.json'}, + {path: 'index.js'} + ], + entryCount: 2 + }, 'JSON output reflects package contents') + t.equal(stderr.trim(), '', 'nothing on stderr') + }) + }) +}) + +test('npm publish --dry-run --json', (t) => { + setup() + return common.npm([ + 'publish', + '--dry-run', + '--json', + '--registry=https://example.registry/fake', + '--cache', path.join(testDir, 'cache'), + '--loglevel=notice', + '--no-color' + ], {'cwd': testDir}) .spread((code, stdout, stderr) => { t.comment(stdout) t.comment(stderr) @@ -132,35 +161,6 @@ test('npm publish --json', (t) => { }, 'JSON output reflects package contents') t.equal(stderr.trim(), '', 'nothing on stderr') }) - }) -}) - -test('npm publish --dry-run --json', (t) => { - setup() - return common.npm([ - 'publish', - '--dry-run', - '--json', - '--registry=https://example.registry/fake', - '--cache', path.join(testDir, 'cache'), - '--loglevel=notice', - '--no-color' - ], {'cwd': testDir}) - .spread((code, stdout, stderr) => { - t.comment(stdout) - t.comment(stderr) - t.is(code, 0, 'published without error') - t.similar(JSON.parse(stdout), { - name: 'publish-organized', - version: '1.2.5', - files: [ - {path: 'package.json'}, - {path: 'index.js'} - ], - entryCount: 2 - }, 'JSON output reflects package contents') - t.equal(stderr.trim(), '', 'nothing on stderr') - }) }) test('cleanup', (t) => { diff --git a/test/tap/repo.js b/test/tap/repo.js index e2751573d..54907f620 100644 --- a/test/tap/repo.js +++ b/test/tap/repo.js @@ -14,7 +14,7 @@ common.pendIfWindows('This is trickier to convert without opening new shells') test('setup', function (t) { var s = '#!/usr/bin/env bash\n' + - 'echo \"$@\" > ' + JSON.stringify(__dirname) + '/_output\n' + 'echo "$@" > ' + JSON.stringify(__dirname) + '/_output\n' fs.writeFileSync(fakeBrowser, s, 'ascii') fs.chmodSync(fakeBrowser, '0755') t.pass('made script') diff --git a/test/tap/retry-on-stale-cache.js b/test/tap/retry-on-stale-cache.js index df6d7c2db..8aec35ed4 100644 --- a/test/tap/retry-on-stale-cache.js +++ b/test/tap/retry-on-stale-cache.js @@ -3,7 +3,6 @@ var path = require('path') var mr = require('npm-registry-mock') var test = require('tap').test var common = require('../common-tap') -var extend = Object.assign || require('util')._extend var Tacks = require('tacks') var Dir = Tacks.Dir var File = Tacks.File @@ -23,7 +22,7 @@ var config = [ var fixture = new Tacks(Dir({ 'cache': Dir(), 'modules': Dir({ - 'good-night-0.1.0.tgz': File(new Buffer( + 'good-night-0.1.0.tgz': File(Buffer.from( '1f8b0800000000000003ed934f4bc43010c57beea7187a59056dd36eff80' + 'de85050541c1f3d8c634da4e4a925a8af8dd6db7bb8ba0e0c15559e9eff2' + '206f929909bc06f327143c6826f51f8d2267cf30c6d2388641c32c61ef75' + @@ -37,7 +36,7 @@ var fixture = new Tacks(Dir({ 'f6795d000c0000', 'hex' )), - 'good-night-1.0.0.tgz': File(new Buffer( + 'good-night-1.0.0.tgz': File(Buffer.from( '1f8b0800000000000003ed954d6bc24010863dfb2bb6b9a8503793b849a0' + 'eda5979efa052d484184252e495a331b76d78a94fef76e8cf683163cd42a' + '957d2e03796777268187543c7de299f0aba6d2472db1b5650020668cd81a' + @@ -79,9 +78,9 @@ var onlyOldMetadata = { } } -var oldAndNewMetadata = extend({}, onlyOldMetadata) +var oldAndNewMetadata = Object.assign({}, onlyOldMetadata) oldAndNewMetadata['dist-tags'] = { latest: '1.0.0' } -oldAndNewMetadata.versions = extend({ +oldAndNewMetadata.versions = Object.assign({ '1.0.0': { 'name': 'good-night', 'version': '1.0.0', diff --git a/test/tap/scripts-whitespace-windows.js b/test/tap/scripts-whitespace-windows.js index 27a04601c..4d1e53a8f 100644 --- a/test/tap/scripts-whitespace-windows.js +++ b/test/tap/scripts-whitespace-windows.js @@ -21,7 +21,7 @@ var json = { description: 'a test', repository: 'git://github.com/robertkowalski/bogus', scripts: { - foo: 'foo --title \"Analysis of\" --recurse -d report src' + foo: 'foo --title "Analysis of" --recurse -d report src' }, dependencies: { 'scripts-whitespace-windows-dep': '0.0.1' @@ -35,8 +35,6 @@ var dependency = { bin: [ 'bin/foo' ] } -var extend = Object.assign || require('util')._extend - var foo = function () { /* #!/usr/bin/env node @@ -65,7 +63,7 @@ test('setup', function (t) { common.npm(['i', dep], { cwd: pkg, - env: extend({ + env: Object.assign({ npm_config_cache: cache, npm_config_tmp: tmp, npm_config_prefix: pkg, diff --git a/test/tap/search.js b/test/tap/search.js index 3568170de..df7ff0fe3 100644 --- a/test/tap/search.js +++ b/test/tap/search.js @@ -164,9 +164,9 @@ test('no arguments provided should error', function (t) { t.equal(code, 1, 'search finished unsuccessfully') t.match( - stderr, - /search must be called with arguments/, - 'should have correct error message' + stderr, + /search must be called with arguments/, + 'should have correct error message' ) t.end() }) diff --git a/test/tap/shared-linked.js b/test/tap/shared-linked.js index 0e2b46278..3ee00e063 100644 --- a/test/tap/shared-linked.js +++ b/test/tap/shared-linked.js @@ -7,7 +7,6 @@ var Symlink = Tacks.Symlink var Dir = Tacks.Dir var common = require('../common-tap.js') var mr = require('npm-registry-mock') -var extend = Object.assign || require('util')._extend var testdir = path.join(__dirname, path.basename(__filename, '.js')) var bugdir = path.join(testdir, 'modules', 'bug') @@ -122,7 +121,7 @@ test('setup', function (t) { test('shared-linked', function (t) { var options = { cwd: bugdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_prefix: path.join(testdir, 'global') }) } diff --git a/test/tap/shrinkwrap-default-dev.js b/test/tap/shrinkwrap-default-dev.js index 5c8929a43..48f9f2a90 100644 --- a/test/tap/shrinkwrap-default-dev.js +++ b/test/tap/shrinkwrap-default-dev.js @@ -5,7 +5,6 @@ var fs = require('fs') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -16,7 +15,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/shrinkwrap-lifecycle-cwd.js b/test/tap/shrinkwrap-lifecycle-cwd.js index a968030e2..bc9ab9cf1 100644 --- a/test/tap/shrinkwrap-lifecycle-cwd.js +++ b/test/tap/shrinkwrap-lifecycle-cwd.js @@ -5,7 +5,6 @@ var mr = require('npm-registry-mock') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -17,7 +16,7 @@ var escapeArg = require('../../lib/utils/escape-arg.js') var conf = { cwd: testdir, - env: extend({ + env: Object.assign({ npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, @@ -87,4 +86,3 @@ test('cleanup', function (t) { cleanup() t.done() }) - diff --git a/test/tap/shrinkwrap-optional-dependency.js b/test/tap/shrinkwrap-optional-dependency.js index 0373e89e6..5085dd0cb 100644 --- a/test/tap/shrinkwrap-optional-dependency.js +++ b/test/tap/shrinkwrap-optional-dependency.js @@ -8,7 +8,7 @@ var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') +var npm = require('../../') var pkg = path.resolve(__dirname, 'shrinkwrap-optional-dependency') diff --git a/test/tap/shrinkwrap-optional-platform.js b/test/tap/shrinkwrap-optional-platform.js index 50a170686..b109d8957 100644 --- a/test/tap/shrinkwrap-optional-platform.js +++ b/test/tap/shrinkwrap-optional-platform.js @@ -4,7 +4,6 @@ var test = require('tap').test var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -15,7 +14,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend(extend({}, process.env), { + env: Object.assign({}, process.env, { npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/shrinkwrap-optional-property.js b/test/tap/shrinkwrap-optional-property.js index 19e55a45f..ccff5a93e 100644 --- a/test/tap/shrinkwrap-optional-property.js +++ b/test/tap/shrinkwrap-optional-property.js @@ -8,7 +8,7 @@ var rimraf = require('rimraf') var test = require('tap').test var common = require('../common-tap.js') -var npm = npm = require('../../') +var npm = require('../../') var pkg = path.resolve(__dirname, 'shrinkwrap-optional-dependency') diff --git a/test/tap/shrinkwrap-prod-dependency.js b/test/tap/shrinkwrap-prod-dependency.js index 023a3bf0b..34e30d7c7 100644 --- a/test/tap/shrinkwrap-prod-dependency.js +++ b/test/tap/shrinkwrap-prod-dependency.js @@ -7,7 +7,7 @@ var osenv = require('osenv') var rimraf = require('rimraf') var test = require('tap').test -var npm = npm = require('../../') +var npm = require('../../') var common = require('../common-tap.js') var pkg = path.resolve(__dirname, 'shrinkwrap-prod-dependency') diff --git a/test/tap/shrinkwrap-resolve-conflict.js b/test/tap/shrinkwrap-resolve-conflict.js index c06be7d59..e85ecec30 100644 --- a/test/tap/shrinkwrap-resolve-conflict.js +++ b/test/tap/shrinkwrap-resolve-conflict.js @@ -30,7 +30,7 @@ test('conflicts in shrinkwrap are auto-resolved on install', (t) => { } }), 'npm-shrinkwrap.json': File( -` + ` { "name": "foo", "requires": true, @@ -84,34 +84,34 @@ test('conflicts in shrinkwrap are auto-resolved on install', (t) => { cb(err || (code && new Error('non-zero exit code')) || null, out) }) }) - .then(() => BB.join( - readJson('npm-shrinkwrap.json'), - readJson('node_modules/modA/package.json'), - readJson('node_modules/modB/package.json'), - readJson('node_modules/modC/package.json'), - (lockfile, A, B, C) => { - t.deepEqual(lockfile, { - name: 'foo', - requires: true, - lockfileVersion: 1, - dependencies: { - modA: { - version: 'file:modA' - }, - modB: { - version: 'file:modB' - }, - modC: { - version: 'file:modC', - dev: true + .then(() => BB.join( + readJson('npm-shrinkwrap.json'), + readJson('node_modules/modA/package.json'), + readJson('node_modules/modB/package.json'), + readJson('node_modules/modC/package.json'), + (lockfile, A, B, C) => { + t.deepEqual(lockfile, { + name: 'foo', + requires: true, + lockfileVersion: 1, + dependencies: { + modA: { + version: 'file:modA' + }, + modB: { + version: 'file:modB' + }, + modC: { + version: 'file:modC', + dev: true + } } - } - }, 'resolved lockfile matches expectations') - t.equal(A.name, 'modA', 'installed modA') - t.equal(B.name, 'modB', 'installed modB') - t.equal(C.name, 'modC', 'installed modC') - } - )) + }, 'resolved lockfile matches expectations') + t.equal(A.name, 'modA', 'installed modA') + t.equal(B.name, 'modB', 'installed modB') + t.equal(C.name, 'modC', 'installed modC') + } + )) }) test('cleanup', () => rimraf(testDir)) diff --git a/test/tap/shrinkwrap-save-dev-with-existing-deps.js b/test/tap/shrinkwrap-save-dev-with-existing-deps.js index 507f2c56f..5934a758d 100644 --- a/test/tap/shrinkwrap-save-dev-with-existing-deps.js +++ b/test/tap/shrinkwrap-save-dev-with-existing-deps.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ var fs = require('fs') var path = require('path') diff --git a/test/tap/shrinkwrap-save-with-existing-dev-deps.js b/test/tap/shrinkwrap-save-with-existing-dev-deps.js index fa8895577..5f0eb0796 100644 --- a/test/tap/shrinkwrap-save-with-existing-dev-deps.js +++ b/test/tap/shrinkwrap-save-with-existing-dev-deps.js @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ var fs = require('fs') var path = require('path') diff --git a/test/tap/spec-local-specifiers.js b/test/tap/spec-local-specifiers.js index 8c8c565dc..d149b7ea0 100644 --- a/test/tap/spec-local-specifiers.js +++ b/test/tap/spec-local-specifiers.js @@ -365,7 +365,7 @@ testdirContent['install-behavior'] = Dir({ } }) }), - 'noext': File(new Buffer( + 'noext': File(Buffer.from( '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' + '06066626260a20dadccc144c1b1841f86000923334363037343536343732' + '633000728c0c80f2d4760836505a5c925804740aa5e640bca200a78708a8' + @@ -373,7 +373,7 @@ testdirContent['install-behavior'] = Dir({ '1928d5720db41b47c1281805a36014501f00005012007200080000', 'hex' )), - 'tarball-1.0.0.tgz': File(new Buffer( + 'tarball-1.0.0.tgz': File(Buffer.from( '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' + '06066626260a20dadccc144c1b1841f8606062a6c060686c606e686a6c68' + '666ec26000e480e5a9ed106ca0b4b824b108e8144acd817845014e0f1150' + diff --git a/test/tap/startstop.js b/test/tap/startstop.js index b17a303c8..0e9d2d940 100644 --- a/test/tap/startstop.js +++ b/test/tap/startstop.js @@ -16,8 +16,8 @@ var json = { name: 'startstop', version: '1.2.3', scripts: { - start: 'node -e \"console.log(\'start\')\"', - stop: 'node -e \"console.log(\'stop\')\"' + start: 'node -e "console.log(\'start\')"', + stop: 'node -e "console.log(\'stop\')"' } } diff --git a/test/tap/symlink-cycle.js b/test/tap/symlink-cycle.js index 62aa8e067..5bee2c556 100644 --- a/test/tap/symlink-cycle.js +++ b/test/tap/symlink-cycle.js @@ -17,7 +17,7 @@ var cycleJSON = { description: '', main: 'index.js', scripts: { - test: 'echo \"Error: no test specified\" && exit 1' + test: 'echo "Error: no test specified" && exit 1' }, dependencies: { 'cycle': '*' diff --git a/test/tap/tagged-version-matching.js b/test/tap/tagged-version-matching.js index a04e74914..55dfb7b7c 100644 --- a/test/tap/tagged-version-matching.js +++ b/test/tap/tagged-version-matching.js @@ -5,7 +5,6 @@ var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir var Symlink = Tacks.Symlink -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -16,7 +15,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend({ + env: Object.assign({ npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/test-run-ls.js b/test/tap/test-run-ls.js index ea495879f..9475695cb 100644 --- a/test/tap/test-run-ls.js +++ b/test/tap/test-run-ls.js @@ -3,7 +3,7 @@ var test = require('tap').test var path = require('path') var cwd = path.resolve(__dirname, '..', '..') var testscript = require('../../package.json').scripts.test -var tsregexp = testscript.replace(/([\[\.\*\]])/g, '\\$1') +var tsregexp = testscript.replace(/([[.*\]])/g, '\\$1') test('default', function (t) { common.npm(['run'], { cwd: cwd }, function (er, code, so) { diff --git a/test/tap/update-examples.js b/test/tap/update-examples.js index 532a67f38..8369d002f 100644 --- a/test/tap/update-examples.js +++ b/test/tap/update-examples.js @@ -149,7 +149,7 @@ test('setup', function (t) { t.pass('mock registry active') npm.load({ cache: CACHE_DIR, registry: common.registry, - cwd: PKG_DIR }, function (err) { + cwd: PKG_DIR }, function (err) { t.ifError(err, 'started server') mockServer = server diff --git a/test/tap/upgrade-lifecycles.js b/test/tap/upgrade-lifecycles.js index f15fe0038..0d0b8da61 100644 --- a/test/tap/upgrade-lifecycles.js +++ b/test/tap/upgrade-lifecycles.js @@ -4,7 +4,6 @@ var test = require('tap').test var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir -var extend = Object.assign || require('util')._extend var common = require('../common-tap.js') var basedir = path.join(__dirname, path.basename(__filename, '.js')) @@ -15,7 +14,7 @@ var tmpdir = path.join(basedir, 'tmp') var conf = { cwd: testdir, - env: extend({ + env: Object.assign({ npm_config_cache: cachedir, npm_config_tmp: tmpdir, npm_config_prefix: globaldir, diff --git a/test/tap/version-allow-same-version.js b/test/tap/version-allow-same-version.js index 9900d28ba..66f568dec 100644 --- a/test/tap/version-allow-same-version.js +++ b/test/tap/version-allow-same-version.js @@ -63,4 +63,3 @@ function setup () { fs.writeFileSync(npmrc, configContents, 'ascii') process.chdir(pkg) } - diff --git a/test/tap/view.js b/test/tap/view.js index 4007db4b5..30ccdb471 100644 --- a/test/tap/view.js +++ b/test/tap/view.js @@ -367,7 +367,7 @@ test('npm view with valid but non existent package name', function (t) { t.equal(code, 1, 'exit not ok') t.similar(stderr, - new RegExp("'valid-but-non-existent-package' is not in the npm registry\."), + new RegExp("'valid-but-non-existent-package' is not in the npm registry\\."), 'Package should NOT be found') t.similar(stderr, new RegExp('use the name yourself!'), |