diff options
author | Rebecca Turner <me@re-becca.org> | 2018-03-23 04:23:24 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2018-03-23 13:46:36 +0300 |
commit | 6d1aac42482a5fee7a38310ee2689050f95de056 (patch) | |
tree | 2edb3cdab3876945d2c25bdc922bf2a451c5560e /test | |
parent | c8146858d6e51411650ad4dc3bc5e294068ed1dc (diff) |
standardize
Diffstat (limited to 'test')
80 files changed, 642 insertions, 662 deletions
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!'), |