summaryrefslogtreecommitdiff
path: root/deps/npm/test
diff options
context:
space:
mode:
authorclaudiahdz <cghr1990@gmail.com>2019-09-03 17:51:04 -0500
committerRich Trott <rtrott@gmail.com>2019-09-17 18:51:21 -0700
commit17e420b23f5462db9f1951d98233fdaee889c721 (patch)
treec0f855138f734517aeba81000ebeac9d6e271563 /deps/npm/test
parent7fa03b54c88f930d24f2f0e2ceb0e94dc5a6ad77 (diff)
downloadandroid-node-v8-17e420b23f5462db9f1951d98233fdaee889c721.tar.gz
android-node-v8-17e420b23f5462db9f1951d98233fdaee889c721.tar.bz2
android-node-v8-17e420b23f5462db9f1951d98233fdaee889c721.zip
deps: update npm to 6.11.3
PR-URL: https://github.com/nodejs/node/pull/29430 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'deps/npm/test')
-rw-r--r--deps/npm/test/common-tap.js8
-rw-r--r--deps/npm/test/fixtures/config/userconfig-with-gc2
-rw-r--r--deps/npm/test/tap/aliases.js6
-rw-r--r--deps/npm/test/tap/anon-cli-metrics.js2
-rw-r--r--deps/npm/test/tap/ci-permissions.js53
-rw-r--r--deps/npm/test/tap/ci.js12
-rw-r--r--deps/npm/test/tap/correct-mkdir.js8
-rw-r--r--deps/npm/test/tap/dist-tag.js31
-rw-r--r--deps/npm/test/tap/ignore-install-link.js2
-rw-r--r--deps/npm/test/tap/install-from-local-multipath.js182
-rw-r--r--deps/npm/test/tap/install-link-metadeps-locally.js52
-rw-r--r--deps/npm/test/tap/install-link-metadeps-subfolders.js68
-rw-r--r--deps/npm/test/tap/install-link-scripts.js4
-rw-r--r--deps/npm/test/tap/lifecycle-INIT_CWD.js2
-rw-r--r--deps/npm/test/tap/lifecycle-path.js (renamed from deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js)25
-rw-r--r--deps/npm/test/tap/ls-l-depth-0.js8
-rw-r--r--deps/npm/test/tap/outdated-depth.js19
-rw-r--r--deps/npm/test/tap/outdated-long.js1
-rw-r--r--deps/npm/test/tap/prepublish-only.js7
-rw-r--r--deps/npm/test/tap/prune.js2
-rw-r--r--deps/npm/test/tap/shared-linked.js2
-rw-r--r--deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js5
-rw-r--r--deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js8
-rw-r--r--deps/npm/test/tap/whoami.js (renamed from deps/npm/test/broken-under-nyc-and-travis/whoami.js)9
24 files changed, 469 insertions, 49 deletions
diff --git a/deps/npm/test/common-tap.js b/deps/npm/test/common-tap.js
index 44b68d719d..83a61f4bdb 100644
--- a/deps/npm/test/common-tap.js
+++ b/deps/npm/test/common-tap.js
@@ -7,6 +7,11 @@ var readCmdShim = require('read-cmd-shim')
var isWindows = require('../lib/utils/is-windows.js')
var Bluebird = require('bluebird')
+if (isWindows) {
+ var PATH = process.env.PATH ? 'PATH' : 'Path'
+ process.env[PATH] += ';C:\\Program Files\\Git\\mingw64\\libexec\\git-core'
+}
+
// remove any git envs so that we don't mess with the main repo
// when running git subprocesses in tests
Object.keys(process.env).filter(k => /^GIT/.test(k)).forEach(
@@ -103,6 +108,7 @@ ourenv.npm_config_globalconfig = exports.npm_config_globalconfig = configCommon.
ourenv.npm_config_global_style = 'false'
ourenv.npm_config_legacy_bundling = 'false'
ourenv.npm_config_fetch_retries = '0'
+ourenv.npm_config_update_notifier = 'false'
ourenv.random_env_var = 'foo'
// suppress warnings about using a prerelease version of node
ourenv.npm_config_node_version = process.version.replace(/-.*$/, '')
@@ -179,7 +185,7 @@ exports.makeGitRepo = function (params, cb) {
var added = params.added || ['package.json']
var message = params.message || 'stub repo'
- var opts = { cwd: root, env: { PATH: process.env.PATH } }
+ var opts = { cwd: root, env: { PATH: process.env.PATH || process.env.Path } }
var commands = [
git.chainableExec(['init'], opts),
git.chainableExec(['config', 'user.name', user], opts),
diff --git a/deps/npm/test/fixtures/config/userconfig-with-gc b/deps/npm/test/fixtures/config/userconfig-with-gc
index cf774bb883..b00d5195bd 100644
--- a/deps/npm/test/fixtures/config/userconfig-with-gc
+++ b/deps/npm/test/fixtures/config/userconfig-with-gc
@@ -1,4 +1,4 @@
-globalconfig = /Users/isaacs/dev/npm/cli/test/fixtures/config/globalconfig
+globalconfig = /Users/claudiahdz/npm/cli/test/fixtures/config/globalconfig
email = i@izs.me
env-thing = ${random_env_var}
init.author.name = Isaac Z. Schlueter
diff --git a/deps/npm/test/tap/aliases.js b/deps/npm/test/tap/aliases.js
index 0a0a9dfd95..21a68ac50f 100644
--- a/deps/npm/test/tap/aliases.js
+++ b/deps/npm/test/tap/aliases.js
@@ -116,18 +116,18 @@ test('installs an npm: protocol alias package', t => {
t.comment(stdout)
t.comment(stderr)
const parsed = JSON.parse(stdout)
- t.deepEqual(parsed, {
+ t.match(parsed, {
foo: {
current: '1.2.3',
wanted: '1.2.4',
latest: '1.2.4',
- location: 'node_modules/foo'
+ location: /node_modules[/\\]foo/
},
bar: {
current: 'npm:foo@1.2.3',
wanted: 'npm:foo@1.2.4',
latest: 'npm:foo@1.2.4',
- location: 'node_modules/bar'
+ location: /node_modules[/\\]bar/
}
}, 'both regular and aliased dependency reported')
return common.npm([
diff --git a/deps/npm/test/tap/anon-cli-metrics.js b/deps/npm/test/tap/anon-cli-metrics.js
index cb1f878a4c..729d9e607a 100644
--- a/deps/npm/test/tap/anon-cli-metrics.js
+++ b/deps/npm/test/tap/anon-cli-metrics.js
@@ -54,7 +54,7 @@ var fixture = new Tacks(Dir({
name: 'slow',
version: '1.0.0',
scripts: {
- preinstall: "node -e 'setTimeout(function(){}, 500)'"
+ preinstall: 'node -e "setTimeout(function(){}, 500)"'
}
})
}),
diff --git a/deps/npm/test/tap/ci-permissions.js b/deps/npm/test/tap/ci-permissions.js
new file mode 100644
index 0000000000..c73d464236
--- /dev/null
+++ b/deps/npm/test/tap/ci-permissions.js
@@ -0,0 +1,53 @@
+const t = require('tap')
+const tar = require('tar')
+const common = require('../common-tap.js')
+const pkg = common.pkg
+const rimraf = require('rimraf')
+const { writeFileSync, statSync, chmodSync } = require('fs')
+const { resolve } = require('path')
+const mkdirp = require('mkdirp')
+
+t.test('setup', t => {
+ mkdirp.sync(resolve(pkg, 'package'))
+ const pj = resolve(pkg, 'package', 'package.json')
+ writeFileSync(pj, JSON.stringify({
+ name: 'foo',
+ version: '1.2.3'
+ }))
+ chmodSync(pj, 0o640)
+ tar.c({
+ sync: true,
+ file: resolve(pkg, 'foo.tgz'),
+ gzip: true,
+ cwd: pkg
+ }, ['package'])
+ writeFileSync(resolve(pkg, 'package.json'), JSON.stringify({
+ name: 'root',
+ version: '1.2.3',
+ dependencies: {
+ foo: 'file:foo.tgz'
+ }
+ }))
+ t.end()
+})
+
+t.test('run install to generate package-lock', t =>
+ common.npm(['install'], { cwd: pkg }).then(([code]) => t.equal(code, 0)))
+
+t.test('remove node_modules', t => rimraf(resolve(pkg, 'node_modules'), t.end))
+
+t.test('run ci and check modes', t =>
+ common.npm(['ci'], { cwd: pkg, stdio: 'inherit' }).then(([code]) => {
+ t.equal(code, 0)
+ const file = resolve(pkg, 'node_modules', 'foo', 'package.json')
+ // bitwise AND against 0o705 so that we can detect whether
+ // the file is world-readable.
+ // Typical unix systems would leave the file 0o644
+ // Travis-ci and some other Linux systems will be 0o664
+ // Windows is 0o666
+ // The regression this is detecting (ie, the default in the tarball)
+ // leaves the file as 0o640.
+ // Bitwise-AND 0o705 should always result in 0o604, and never 0o600
+ const mode = statSync(file).mode & 0o705
+ t.equal(mode, 0o604)
+ }))
diff --git a/deps/npm/test/tap/ci.js b/deps/npm/test/tap/ci.js
index 9150f26efe..3f3e251d03 100644
--- a/deps/npm/test/tap/ci.js
+++ b/deps/npm/test/tap/ci.js
@@ -19,6 +19,9 @@ const EXEC_OPTS = { cwd: testDir }
const PKG = {
name: 'top',
version: '1.2.3',
+ scripts: {
+ install: 'node -p process.env.npm_config_foo'
+ },
dependencies: {
optimist: '0.6.0',
clean: '2.1.6'
@@ -77,6 +80,7 @@ test('basic installation', (t) => {
.then(() => fixture.create(testDir))
.then(() => common.npm([
'ci',
+ '--foo=asdf',
'--registry', common.registry,
'--loglevel', 'warn'
], EXEC_OPTS))
@@ -88,7 +92,7 @@ test('basic installation', (t) => {
t.equal(stderr.trim(), '', 'no output on stderr')
t.match(
stdout.trim(),
- /^added 6 packages in \d+(?:\.\d+)?s$/,
+ /\nasdf\nadded 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'))
@@ -144,6 +148,7 @@ test('supports npm-shrinkwrap.json as well', (t) => {
.then(() => fixture.create(testDir))
.then(() => common.npm([
'ci',
+ '--foo=asdf',
'--registry', common.registry,
'--loglevel', 'warn'
], EXEC_OPTS))
@@ -155,7 +160,7 @@ test('supports npm-shrinkwrap.json as well', (t) => {
t.equal(stderr.trim(), '', 'no output on stderr')
t.match(
stdout.trim(),
- /^added 6 packages in \d+(?:\.\d+)?s$/,
+ /\nasdf\nadded 6 packages in \d+(?:\.\d+)?s$/,
'no warnings on stderr, and final output has right number of packages'
)
})
@@ -194,6 +199,7 @@ test('removes existing node_modules/ before installing', (t) => {
.then(() => fixture.create(testDir))
.then(() => common.npm([
'ci',
+ '--foo=asdf',
'--registry', common.registry,
'--loglevel', 'warn'
], EXEC_OPTS))
@@ -232,6 +238,7 @@ test('errors if package-lock.json missing', (t) => {
.then(() => fixture.create(testDir))
.then(() => common.npm([
'ci',
+ '--foo=asdf',
'--registry', common.registry,
'--loglevel', 'warn'
], EXEC_OPTS))
@@ -268,6 +275,7 @@ test('errors if package-lock.json invalid', (t) => {
.then(() => fixture.create(testDir))
.then(() => common.npm([
'ci',
+ '--foo=asdf',
'--registry', common.registry,
'--loglevel', 'warn'
], EXEC_OPTS))
diff --git a/deps/npm/test/tap/correct-mkdir.js b/deps/npm/test/tap/correct-mkdir.js
index 5c2e9771df..30907d725c 100644
--- a/deps/npm/test/tap/correct-mkdir.js
+++ b/deps/npm/test/tap/correct-mkdir.js
@@ -1,10 +1,16 @@
/* eslint-disable camelcase */
-var test = require('tap').test
+var t = require('tap')
+var test = t.test
var assert = require('assert')
var requireInject = require('require-inject')
const common = require('../common-tap.js')
var cache_dir = common.pkg
+if (process.platform === 'win32') {
+ t.plan(0, 'windows does not use correct-mkdir behavior')
+ process.exit(0)
+}
+
test('correct-mkdir: no race conditions', function (t) {
var mock_fs = {}
var did_hook = false
diff --git a/deps/npm/test/tap/dist-tag.js b/deps/npm/test/tap/dist-tag.js
index 0567964d35..a5cce5d2a0 100644
--- a/deps/npm/test/tap/dist-tag.js
+++ b/deps/npm/test/tap/dist-tag.js
@@ -46,6 +46,12 @@ function mocks (server) {
server.delete('/-/package/@scoped%2fanother/dist-tags/c')
.reply(200, { c: '7.7.7' })
+ // using a scoped registry
+ server.get('/-/package/@scoped%2ffoo/dist-tags')
+ .reply(200, { latest: '2.0.0', a: '0.0.2', b: '0.6.0' })
+ server.delete('/-/package/@scoped%2ffoo/dist-tags/b')
+ .reply(200, { b: '0.6.0' })
+
// rm
server.get('/-/package/@scoped%2fanother/dist-tags')
.reply(200, { latest: '4.0.0' })
@@ -232,6 +238,31 @@ test('npm dist-tags rm @scoped/another nonexistent', function (t) {
)
})
+test('npm dist-tags rm with registry assigned to scope', function (t) {
+ fs.writeFileSync(path.resolve(pkg, '.npmrc'), `
+@scoped:registry=${common.registry}
+${common.registry.replace(/^https?:/, '')}:_authToken=taken
+`)
+
+ common.npm(
+ [
+ 'dist-tags',
+ 'rm', '@scoped/foo', 'b',
+ '--loglevel', 'silent',
+ '--userconfig', path.resolve(pkg, '.npmrc')
+ ],
+ { cwd: pkg },
+ function (er, code, stdout, stderr) {
+ t.ifError(er, 'npm access')
+ t.notOk(code, 'exited OK')
+ t.notOk(stderr, 'no error output')
+ t.equal(stdout, '-b: @scoped/foo@0.6.0\n')
+
+ t.end()
+ }
+ )
+})
+
test('cleanup', function (t) {
t.pass('cleaned up')
rimraf.sync(pkg)
diff --git a/deps/npm/test/tap/ignore-install-link.js b/deps/npm/test/tap/ignore-install-link.js
index 7b3b1be3b9..a2caa23dfd 100644
--- a/deps/npm/test/tap/ignore-install-link.js
+++ b/deps/npm/test/tap/ignore-install-link.js
@@ -1,5 +1,5 @@
if (process.platform === 'win32') {
- console.log('ok - symlinks are weird on windows, skip this test')
+ require('tap').plan(0, 'symlinks are weird on windows, skip this test')
process.exit(0)
}
var common = require('../common-tap.js')
diff --git a/deps/npm/test/tap/install-from-local-multipath.js b/deps/npm/test/tap/install-from-local-multipath.js
new file mode 100644
index 0000000000..83dbdadde9
--- /dev/null
+++ b/deps/npm/test/tap/install-from-local-multipath.js
@@ -0,0 +1,182 @@
+var fs = require('graceful-fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap')
+
+var root = common.pkg
+// Allow running this test on older commits (useful for bisecting)
+if (!root) {
+ var main = require.main.filename
+ root = path.resolve(path.dirname(main), path.basename(main, '.js'))
+}
+var pkg = path.join(root, 'parent')
+
+var EXEC_OPTS = { cwd: pkg }
+
+var parent = {
+ name: 'parent',
+ version: '0.0.0',
+ dependencies: {
+ 'child-1-1': 'file:../children/child-1-1',
+ 'child-1-2': 'file:../children/child-1-2',
+ 'child-2': 'file:../children/child-2'
+ }
+}
+
+var parentLock = {
+ 'name': 'parent',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-1-1': {
+ 'version': 'file:../children/child-1-1',
+ 'requires': {
+ 'child-2': 'file:../children/child-2'
+ }
+ },
+ 'child-1-2': {
+ 'version': 'file:../children/child-1-2',
+ 'requires': {
+ 'child-1-1': 'file:../children/child-1-1',
+ 'child-2': 'file:../children/child-2'
+ }
+ },
+ 'child-2': {
+ 'version': 'file:../children/child-2'
+ }
+ }
+}
+
+var child11 = {
+ name: 'parent',
+ version: '0.0.0',
+ 'dependencies': {
+ 'child-2': 'file:../child-2'
+ }
+}
+
+var child11Lock = {
+ 'name': 'child-1-1',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-2': {
+ 'version': 'file:../child-2'
+ }
+ }
+}
+
+var child12 = {
+ 'name': 'child-1-2',
+ 'version': '1.0.0',
+ 'dependencies': {
+ 'child-1-1': 'file:../child-1-1',
+ 'child-2': 'file:../child-2'
+ }
+}
+
+var child12Lock = {
+ 'name': 'child-1-2',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-1-1': {
+ 'version': 'file:../child-1-1',
+ 'requires': {
+ 'child-2': 'file:../child-2'
+ }
+ },
+ 'child-2': {
+ 'version': 'file:../child-2'
+ }
+ }
+}
+
+var child2 = {
+ 'name': 'child-2',
+ 'version': '1.0.0',
+ 'dependencies': {}
+}
+
+var child2Lock = {
+ 'name': 'child-2',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {}
+}
+
+test('setup', function (t) {
+ rimraf.sync(pkg)
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(parent, null, 2)
+ )
+
+ fs.writeFileSync(
+ path.join(pkg, 'package-lock.json'),
+ JSON.stringify(parentLock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-1-1'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-1', 'package.json'),
+ JSON.stringify(child11, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-1', 'package-lock.json'),
+ JSON.stringify(child11Lock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-1-2'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-2', 'package.json'),
+ JSON.stringify(child12, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-2', 'package-lock.json'),
+ JSON.stringify(child12Lock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-2'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-2', 'package.json'),
+ JSON.stringify(child2, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-2', 'package-lock.json'),
+ JSON.stringify(child2Lock, null, 2)
+ )
+
+ process.chdir(pkg)
+ t.end()
+})
+
+test('\'npm install\' should install local packages', function (t) {
+ common.npm(
+ [
+ 'install', '.'
+ ],
+ EXEC_OPTS,
+ function (err, code) {
+ t.ifError(err, 'error should not exist')
+ t.notOk(code, 'npm install exited with code 0')
+ t.end()
+ }
+ )
+})
+
+test('cleanup', function (t) {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(root)
+ t.end()
+})
diff --git a/deps/npm/test/tap/install-link-metadeps-locally.js b/deps/npm/test/tap/install-link-metadeps-locally.js
new file mode 100644
index 0000000000..136fd46d10
--- /dev/null
+++ b/deps/npm/test/tap/install-link-metadeps-locally.js
@@ -0,0 +1,52 @@
+// XXX Remove in npm v7, when this is no longer how we do things
+const t = require('tap')
+const common = require('../common-tap.js')
+const pkg = common.pkg
+const mkdirp = require('mkdirp')
+const { writeFileSync, statSync } = require('fs')
+const { resolve } = require('path')
+const mr = require('npm-registry-mock')
+const rimraf = require('rimraf')
+
+t.test('setup', t => {
+ mkdirp.sync(resolve(pkg, 'node_modules'))
+ mkdirp.sync(resolve(pkg, 'foo'))
+ writeFileSync(resolve(pkg, 'foo', 'package.json'), JSON.stringify({
+ name: 'foo',
+ version: '1.2.3',
+ dependencies: {
+ underscore: '*'
+ }
+ }))
+
+ writeFileSync(resolve(pkg, 'package.json'), JSON.stringify({
+ name: 'root',
+ version: '1.2.3',
+ dependencies: {
+ foo: 'file:foo'
+ }
+ }))
+
+ mr({ port: common.port }, (er, s) => {
+ if (er) {
+ throw er
+ }
+ t.parent.teardown(() => s.close())
+ t.end()
+ })
+})
+
+t.test('initial install to create package-lock',
+ t => common.npm(['install', '--registry', common.registry], { cwd: pkg })
+ .then(([code]) => t.equal(code, 0, 'command worked')))
+
+t.test('remove node_modules', t =>
+ rimraf(resolve(pkg, 'node_modules'), t.end))
+
+t.test('install again from package-lock', t =>
+ common.npm(['install', '--registry', common.registry], { cwd: pkg })
+ .then(([code]) => {
+ t.equal(code, 0, 'command worked')
+ const underscore = resolve(pkg, 'node_modules', 'underscore')
+ t.equal(statSync(underscore).isDirectory(), true, 'underscore installed')
+ }))
diff --git a/deps/npm/test/tap/install-link-metadeps-subfolders.js b/deps/npm/test/tap/install-link-metadeps-subfolders.js
new file mode 100644
index 0000000000..7544c8a4eb
--- /dev/null
+++ b/deps/npm/test/tap/install-link-metadeps-subfolders.js
@@ -0,0 +1,68 @@
+const t = require('tap')
+const common = require('../common-tap.js')
+const mkdirp = require('mkdirp')
+const { writeFileSync, readFileSync } = require('fs')
+const { resolve } = require('path')
+const pkg = common.pkg
+const app = resolve(pkg, 'app')
+const lib = resolve(pkg, 'lib')
+const moda = resolve(lib, 'module-a')
+const modb = resolve(lib, 'module-b')
+
+const rimraf = require('rimraf')
+
+t.test('setup', t => {
+ mkdirp.sync(app)
+ mkdirp.sync(moda)
+ mkdirp.sync(modb)
+
+ writeFileSync(resolve(app, 'package.json'), JSON.stringify({
+ name: 'app',
+ version: '1.2.3',
+ dependencies: {
+ moda: 'file:../lib/module-a'
+ }
+ }))
+
+ writeFileSync(resolve(moda, 'package.json'), JSON.stringify({
+ name: 'moda',
+ version: '1.2.3',
+ dependencies: {
+ modb: 'file:../module-b'
+ }
+ }))
+
+ writeFileSync(resolve(modb, 'package.json'), JSON.stringify({
+ name: 'modb',
+ version: '1.2.3'
+ }))
+
+ t.end()
+})
+
+t.test('initial install to create package-lock',
+ t => common.npm(['install'], { cwd: app })
+ .then(([code]) => t.equal(code, 0, 'command worked')))
+
+t.test('remove node_modules', t =>
+ rimraf(resolve(pkg, 'node_modules'), t.end))
+
+t.test('install again from package-lock', t =>
+ common.npm(['install'], { cwd: app })
+ .then(([code]) => {
+ t.equal(code, 0, 'command worked')
+ // verify that module-b is linked under module-a
+ const depPkg = resolve(
+ app,
+ 'node_modules',
+ 'moda',
+ 'node_modules',
+ 'modb',
+ 'package.json'
+ )
+ const data = JSON.parse(readFileSync(depPkg, 'utf8'))
+ t.strictSame(data, {
+ name: 'modb',
+ version: '1.2.3'
+ })
+ }))
diff --git a/deps/npm/test/tap/install-link-scripts.js b/deps/npm/test/tap/install-link-scripts.js
index bff4dd5ef0..3553e63773 100644
--- a/deps/npm/test/tap/install-link-scripts.js
+++ b/deps/npm/test/tap/install-link-scripts.js
@@ -1,3 +1,7 @@
+if (process.platform === 'win32') {
+ require('tap').plan(0, 'links are weird on windows, skip this')
+ process.exit(0)
+}
var fs = require('graceful-fs')
var path = require('path')
diff --git a/deps/npm/test/tap/lifecycle-INIT_CWD.js b/deps/npm/test/tap/lifecycle-INIT_CWD.js
index e035cf86d4..3e9c1c8257 100644
--- a/deps/npm/test/tap/lifecycle-INIT_CWD.js
+++ b/deps/npm/test/tap/lifecycle-INIT_CWD.js
@@ -15,7 +15,7 @@ var json = {
name: 'init-cwd',
version: '1.0.0',
scripts: {
- initcwd: 'echo "$INIT_CWD"'
+ initcwd: process.platform === 'win32' ? 'echo %INIT_CWD%' : 'echo "$INIT_CWD"'
}
}
diff --git a/deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js b/deps/npm/test/tap/lifecycle-path.js
index 6209319b41..70fb839197 100644
--- a/deps/npm/test/broken-under-nyc-and-travis/lifecycle-path.js
+++ b/deps/npm/test/tap/lifecycle-path.js
@@ -2,14 +2,14 @@ var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
-var osenv = require('osenv')
var rimraf = require('rimraf')
+var which = require('which')
var test = require('tap').test
var common = require('../common-tap.js')
var isWindows = require('../../lib/utils/is-windows.js')
-var pkg = path.resolve(__dirname, 'lifecycle-path')
+var pkg = common.pkg
var PATH
if (isWindows) {
@@ -21,9 +21,10 @@ if (isWindows) {
PATH = '/bin:/usr/bin'
}
+var systemNode = which.sync('node', { nothrow: true, path: PATH })
+// the path to the system wide node (null if none)
+
test('setup', function (t) {
- cleanup()
- mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify({}, null, 2)
@@ -183,6 +184,12 @@ function checkPath (testconfig, t) {
'The node binary used for scripts is.*' +
process.execPath.replace(/[/\\]/g, '.'))
t.match(stderr, regex, 'reports the current binary vs conflicting')
+ } else if (systemNode !== null) {
+ var regexSystemNode = new RegExp(
+ 'The node binary used for scripts is.*' +
+ systemNode.replace(/[/\\]/g, '.')
+ )
+ t.match(stderr, regexSystemNode, 'reports the system binary vs conflicting')
} else {
t.match(stderr, /there is no node binary in the current PATH/, 'informs user that there is no node binary in PATH')
}
@@ -201,13 +208,3 @@ function checkPath (testconfig, t) {
t.end()
})
}
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/ls-l-depth-0.js b/deps/npm/test/tap/ls-l-depth-0.js
index 8459bd5203..b2516c9fa2 100644
--- a/deps/npm/test/tap/ls-l-depth-0.js
+++ b/deps/npm/test/tap/ls-l-depth-0.js
@@ -67,10 +67,12 @@ test('#6311: npm ll --depth=0 duplicates listing', function (t) {
if (err) throw err
t.notOk(code, 'npm install exited cleanly')
t.is(stderr, '', 'npm install ran silently')
- t.equal(
+ t.match(
stdout.trim(),
- 'add\tunderscore\t1.5.1\tnode_modules/underscore\t\t\n' +
- 'add\tglock\t1.8.7\tnode_modules/glock',
+ new RegExp(
+ '^add\tunderscore\t1[.]5[.]1\tnode_modules[\\\\/]underscore\t\t[\n]' +
+ 'add\tglock\t1[.]8[.]7\tnode_modules[\\\\/]glock$'
+ ),
'got expected install output'
)
diff --git a/deps/npm/test/tap/outdated-depth.js b/deps/npm/test/tap/outdated-depth.js
index 5cf7c7edac..8e272e6002 100644
--- a/deps/npm/test/tap/outdated-depth.js
+++ b/deps/npm/test/tap/outdated-depth.js
@@ -47,6 +47,7 @@ test('outdated depth zero', function (t) {
mr({ port: common.port }, function (er, s) {
npm.load(
{
+ depth: 0,
loglevel: 'silent',
registry: common.registry
},
@@ -54,12 +55,24 @@ test('outdated depth zero', function (t) {
npm.install('.', function (er) {
if (er) throw new Error(er)
npm.outdated(function (err, d) {
- t.ifError(err, 'npm outdated ran without error')
+ if (err) {
+ throw err
+ }
t.is(process.exitCode, 1, 'exit code set to 1')
process.exitCode = 0
t.deepEqual(d[0], expected)
- s.close()
- t.end()
+ t.equal(d.length, 1)
+ npm.config.set('depth', 1)
+ npm.outdated(function (err, d) {
+ t.equal(d.length, 2)
+ if (err) {
+ throw err
+ }
+ t.is(process.exitCode, 1, 'exit code set to 1')
+ process.exitCode = 0
+ s.close()
+ t.end()
+ })
})
})
}
diff --git a/deps/npm/test/tap/outdated-long.js b/deps/npm/test/tap/outdated-long.js
index 0a33881598..8cd2ceadb9 100644
--- a/deps/npm/test/tap/outdated-long.js
+++ b/deps/npm/test/tap/outdated-long.js
@@ -79,6 +79,7 @@ test('it should not throw', function (t) {
t.is(process.exitCode, 1, 'exit code set to 1')
process.exitCode = 0
console.log = originalLog
+ output[0] = output[0].replace(/\\/g, '/')
t.same(output, expOut)
t.same(d, expData)
diff --git a/deps/npm/test/tap/prepublish-only.js b/deps/npm/test/tap/prepublish-only.js
index 57af26038a..56881494d2 100644
--- a/deps/npm/test/tap/prepublish-only.js
+++ b/deps/npm/test/tap/prepublish-only.js
@@ -17,7 +17,6 @@ var tmpdir = join(pkg, 'tmp')
var env = {
'npm_config_cache': cachedir,
'npm_config_tmp': tmpdir,
- 'npm_config_prefix': pkg,
'npm_config_global': 'false'
}
@@ -64,7 +63,6 @@ var fixture = new Tacks(Dir({
}))
test('setup', function (t) {
- cleanup()
fixture.create(pkg)
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
t.ifError(err, 'registry mocked successfully')
@@ -131,12 +129,7 @@ test('test', function (t) {
})
test('cleanup', function (t) {
- cleanup()
server.close()
t.pass('cleaned up')
t.end()
})
-
-function cleanup () {
- fixture.remove(pkg)
-}
diff --git a/deps/npm/test/tap/prune.js b/deps/npm/test/tap/prune.js
index 936ee3a91b..ce2a300b1a 100644
--- a/deps/npm/test/tap/prune.js
+++ b/deps/npm/test/tap/prune.js
@@ -104,7 +104,7 @@ test('production: npm prune', function (t) {
], EXEC_OPTS, function (err, code, stdout) {
if (err) throw err
t.notOk(code, 'exit ok')
- t.equal(stdout.trim(), 'remove\tmkdirp\t0.3.5\tnode_modules/mkdirp')
+ t.equal(stdout.trim().replace(/\\/g, '/'), 'remove\tmkdirp\t0.3.5\tnode_modules/mkdirp')
t.end()
})
})
diff --git a/deps/npm/test/tap/shared-linked.js b/deps/npm/test/tap/shared-linked.js
index cbdbcf66c1..517be4699d 100644
--- a/deps/npm/test/tap/shared-linked.js
+++ b/deps/npm/test/tap/shared-linked.js
@@ -133,7 +133,7 @@ test('shared-linked', function (t) {
common.npm(config.concat(['install', '--dry-run', '--parseable']), options, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0)
- var got = stdout.trim().replace(/\s+\n/g, '\n')
+ var got = stdout.trim().replace(/\s+\n/g, '\n').replace(/\\/g, '/')
var expected =
'add\tminimist\t0.0.5\tnode_modules/minimist\n' +
'add\twordwrap\t0.0.2\tnode_modules/wordwrap\n' +
diff --git a/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js b/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
index f8927df5a2..78f40f5297 100644
--- a/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
+++ b/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
@@ -12,7 +12,6 @@ var testdir = path.join(basedir, 'testdir')
var cachedir = common.cache
var globaldir = path.join(basedir, 'global')
var tmpdir = path.join(basedir, 'tmp')
-var escapeArg = require('../../lib/utils/escape-arg.js')
var conf = {
cwd: testdir,
@@ -39,8 +38,8 @@ var fixture = new Tacks(Dir({
// add this to the end of the command to preserve the debug log:
// || mv npm-debug.log real-debug.log
// removed for windows compat reasons
- abc: escapeArg(common.nodeBin) + ' ' + escapeArg(common.bin) + ' shrinkwrap',
- shrinkwrap: escapeArg(common.nodeBin) + ' scripts/shrinkwrap.js'
+ abc: 'node ' + JSON.stringify(common.bin) + ' shrinkwrap',
+ shrinkwrap: 'node scripts/shrinkwrap.js'
}
}),
scripts: Dir({
diff --git a/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js b/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js
index fcbbeeffdd..8a3f449fa8 100644
--- a/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js
+++ b/deps/npm/test/tap/shrinkwrap-save-with-existing-dev-deps.js
@@ -18,7 +18,13 @@ var example_pkg = path.join(example, 'package.json')
var installed = path.join(example, 'node_modules', 'installed')
var installed_pkg = path.join(installed, 'package.json')
-var EXEC_OPTS = { cwd: example }
+// Ignore max listeners warnings until that gets fixed
+var env = Object.keys(process.env).reduce((set, key) => {
+ if (!set[key]) set[key] = process.env[key]
+ return set
+}, { NODE_NO_WARNINGS: '1' })
+
+var EXEC_OPTS = { cwd: example, env: env }
var installme_pkg_json = {
name: 'installme',
diff --git a/deps/npm/test/broken-under-nyc-and-travis/whoami.js b/deps/npm/test/tap/whoami.js
index a5668b1210..9f4bf4266b 100644
--- a/deps/npm/test/broken-under-nyc-and-travis/whoami.js
+++ b/deps/npm/test/tap/whoami.js
@@ -9,14 +9,14 @@ var rimraf = require('rimraf')
var opts = { cwd: __dirname }
-var FIXTURE_PATH = path.resolve(__dirname, 'fixture_npmrc')
+var FIXTURE_PATH = path.resolve(common.pkg, 'fixture_npmrc')
test('npm whoami with basic auth', function (t) {
var s = '//registry.lvh.me/:username = wombat\n' +
'//registry.lvh.me/:_password = YmFkIHBhc3N3b3Jk\n' +
'//registry.lvh.me/:email = lindsay@wdu.org.au\n'
fs.writeFileSync(FIXTURE_PATH, s, 'ascii')
- fs.chmodSync(FIXTURE_PATH, '0444')
+ fs.chmodSync(FIXTURE_PATH, 0o644)
common.npm(
[
@@ -31,17 +31,16 @@ test('npm whoami with basic auth', function (t) {
t.equal(stderr, '', 'got nothing on stderr')
t.equal(code, 0, 'exit ok')
t.equal(stdout, 'wombat\n', 'got username')
- rimraf.sync(FIXTURE_PATH)
t.end()
}
)
})
-test('npm whoami with bearer auth', { timeout: 2 * 1000 }, function (t) {
+test('npm whoami with bearer auth', { timeout: 6000 }, function (t) {
var s = '//localhost:' + common.port +
'/:_authToken = wombat-developers-union\n'
fs.writeFileSync(FIXTURE_PATH, s, 'ascii')
- fs.chmodSync(FIXTURE_PATH, '0444')
+ fs.chmodSync(FIXTURE_PATH, 0o644)
function verify (req, res) {
t.equal(req.method, 'GET')