summaryrefslogtreecommitdiff
path: root/deps/npm/test
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2016-10-25 17:07:19 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2016-11-04 17:51:05 -0400
commit379097850d714494b3cfb92803d79d9999c983ef (patch)
tree08fc64801758d6239872540e05e0e6952cd40c8c /deps/npm/test
parent1a55e9a5672ec654a6cfdd694c20b7067368f5e9 (diff)
downloadandroid-node-v8-379097850d714494b3cfb92803d79d9999c983ef.tar.gz
android-node-v8-379097850d714494b3cfb92803d79d9999c983ef.tar.bz2
android-node-v8-379097850d714494b3cfb92803d79d9999c983ef.zip
deps: upgrade npm to 3.10.9
PR-URL: https://github.com/nodejs/node/pull/9286 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/test')
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds-package.js4
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds.js4
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut.js4
-rw-r--r--deps/npm/test/tap/gist-short-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/gist-short-shortcut.js4
-rw-r--r--deps/npm/test/tap/gist-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/gist-shortcut.js4
-rw-r--r--deps/npm/test/tap/git-races.js7
-rw-r--r--deps/npm/test/tap/github-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/gitlab-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/gitlab-shortcut.js4
-rw-r--r--deps/npm/test/tap/install-bin-null.js91
-rw-r--r--deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js89
-rw-r--r--deps/npm/test/tap/tagged-version-matching.js162
-rw-r--r--deps/npm/test/tap/upgrade-lifecycles.js89
-rw-r--r--deps/npm/test/tap/version-sub-directory-shrinkwrap.js80
-rw-r--r--deps/npm/test/tap/view.js464
18 files changed, 773 insertions, 253 deletions
diff --git a/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js b/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js
index e5a4142ef3..7268b50400 100644
--- a/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js
+++ b/deps/npm/test/tap/bitbucket-https-url-with-creds-package.js
@@ -34,10 +34,10 @@ test('bitbucket-https-url-with-creds-package', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/bitbucket-https-url-with-creds.js b/deps/npm/test/tap/bitbucket-https-url-with-creds.js
index 4e9d14d7e0..846e3ae741 100644
--- a/deps/npm/test/tap/bitbucket-https-url-with-creds.js
+++ b/deps/npm/test/tap/bitbucket-https-url-with-creds.js
@@ -31,10 +31,10 @@ test('bitbucket-https-url-with-creds', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/bitbucket-shortcut-package.js b/deps/npm/test/tap/bitbucket-shortcut-package.js
index 69cfe6c205..37fe57950c 100644
--- a/deps/npm/test/tap/bitbucket-shortcut-package.js
+++ b/deps/npm/test/tap/bitbucket-shortcut-package.js
@@ -35,10 +35,10 @@ test('bitbucket-shortcut', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/bitbucket-shortcut.js b/deps/npm/test/tap/bitbucket-shortcut.js
index a9b60f8b56..a708d84972 100644
--- a/deps/npm/test/tap/bitbucket-shortcut.js
+++ b/deps/npm/test/tap/bitbucket-shortcut.js
@@ -32,10 +32,10 @@ test('bitbucket-shortcut', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gist-short-shortcut-package.js b/deps/npm/test/tap/gist-short-shortcut-package.js
index 02457b4dc9..c15e1df7e2 100644
--- a/deps/npm/test/tap/gist-short-shortcut-package.js
+++ b/deps/npm/test/tap/gist-short-shortcut-package.js
@@ -35,10 +35,10 @@ test('gist-short-shortcut-package', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gist-short-shortcut.js b/deps/npm/test/tap/gist-short-shortcut.js
index 58dcf78e8d..c7d217f9a9 100644
--- a/deps/npm/test/tap/gist-short-shortcut.js
+++ b/deps/npm/test/tap/gist-short-shortcut.js
@@ -32,10 +32,10 @@ test('gist-shortcut', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gist-shortcut-package.js b/deps/npm/test/tap/gist-shortcut-package.js
index 370476ac80..e35ab71e84 100644
--- a/deps/npm/test/tap/gist-shortcut-package.js
+++ b/deps/npm/test/tap/gist-shortcut-package.js
@@ -35,10 +35,10 @@ test('gist-shortcut-package', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gist-shortcut.js b/deps/npm/test/tap/gist-shortcut.js
index e975a09b3e..3b48e47009 100644
--- a/deps/npm/test/tap/gist-shortcut.js
+++ b/deps/npm/test/tap/gist-shortcut.js
@@ -32,10 +32,10 @@ test('gist-shortcut', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/git-races.js b/deps/npm/test/tap/git-races.js
index 6bbfe78bd7..f275455cd0 100644
--- a/deps/npm/test/tap/git-races.js
+++ b/deps/npm/test/tap/git-races.js
@@ -60,9 +60,12 @@ function cleanup () {
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
'execFile': function (cmd, args, options, cb) {
+ // on win 32, the following prefix is added in utils/git.js
+ // $ git -c core.longpaths=true clone
+ var i = process.platform === 'win32' ? 2 : 0
// If it's a clone we swap any requests for any of the urls we're mocking
// with the path to the bare repo
- if (args[0] === 'clone') {
+ if (args[i] === 'clone') {
var m2 = args.length - 2
var m1 = args.length - 1
if (testrepos[args[m2]]) {
@@ -72,7 +75,7 @@ var npm = requireInject.installGlobally('../../lib/npm.js', {
execFile(cmd, args, options, cb)
// here, we intercept npm validating the remote origin url on one of the
// clones we've done previously and return the original url that was requested
- } else if (args[0] === 'config' && args[1] === '--get' && args[2] === 'remote.origin.url') {
+ } else if (args[i] === 'config' && args[i + 1] === '--get' && args[i + 2] === 'remote.origin.url') {
process.nextTick(function () {
cb(null, testurls[options.cwd], '')
})
diff --git a/deps/npm/test/tap/github-shortcut-package.js b/deps/npm/test/tap/github-shortcut-package.js
index 13c6806b01..e1a4b306cc 100644
--- a/deps/npm/test/tap/github-shortcut-package.js
+++ b/deps/npm/test/tap/github-shortcut-package.js
@@ -35,10 +35,10 @@ test('github-shortcut-package', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gitlab-shortcut-package.js b/deps/npm/test/tap/gitlab-shortcut-package.js
index 76cd7f911b..335bc4d60a 100644
--- a/deps/npm/test/tap/gitlab-shortcut-package.js
+++ b/deps/npm/test/tap/gitlab-shortcut-package.js
@@ -34,10 +34,10 @@ test('gitlab-shortcut-package', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/gitlab-shortcut.js b/deps/npm/test/tap/gitlab-shortcut.js
index 96da268ee0..dcba064bc1 100644
--- a/deps/npm/test/tap/gitlab-shortcut.js
+++ b/deps/npm/test/tap/gitlab-shortcut.js
@@ -31,10 +31,10 @@ test('gitlab-shortcut', function (t) {
'child_process': {
'execFile': function (cmd, args, options, cb) {
process.nextTick(function () {
- if (args[0] !== 'clone') return cb(null, '', '')
+ if (args.indexOf('clone') === -1) return cb(null, '', '')
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[3], cloneUrl[0], cloneUrl[1])
+ t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
diff --git a/deps/npm/test/tap/install-bin-null.js b/deps/npm/test/tap/install-bin-null.js
new file mode 100644
index 0000000000..f45528a75a
--- /dev/null
+++ b/deps/npm/test/tap/install-bin-null.js
@@ -0,0 +1,91 @@
+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.js')
+
+var pkg = path.join(__dirname, 'install-bin-null')
+
+var EXEC_OPTS = { cwd: pkg }
+
+var parentPkg = {
+ name: 'parent-package',
+ version: '0.0.0',
+ dependencies: {
+ 'child-package-a': 'file:./child-package-a',
+ 'child-package-b': 'file:./child-package-b'
+ }
+}
+
+var childPkgA = {
+ name: 'child-package-a',
+ version: '0.0.0',
+ bin: 'index.js'
+}
+
+var childPkgB = {
+ name: 'child-package-b',
+ version: '0.0.0',
+ dependencies: {
+ 'grandchild-package': 'file:../grandchild-package'
+ }
+}
+
+var grandchildPkg = {
+ name: 'grandchild-package',
+ version: '0.0.0',
+ bin: null
+}
+
+var pkgs = [childPkgA, childPkgB, grandchildPkg]
+
+test('the grandchild has bin:null', function (t) {
+ setup()
+ common.npm(['install'], EXEC_OPTS, function (err, code, stdout, stderr) {
+ t.ifErr(err, 'npm link finished without error')
+ t.equal(code, 0, 'exited ok')
+ t.ok(stdout, 'output indicating success')
+ t.notOk(stderr, 'no output stderr')
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+}
+
+function setup () {
+ cleanup()
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(parentPkg, null, 2)
+ )
+ pkgs.forEach(function (json) {
+ process.chdir(mkPkg(json))
+ })
+ fs.writeFileSync(
+ path.join(pkg, childPkgA.name, 'index.js'),
+ ''
+ )
+}
+
+function mkPkg (json) {
+ var pkgPath = path.resolve(pkg, json.name)
+ mkdirp.sync(pkgPath)
+ fs.writeFileSync(
+ path.join(pkgPath, 'package.json'),
+ JSON.stringify(json, null, 2)
+ )
+ return pkgPath
+}
diff --git a/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js b/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
new file mode 100644
index 0000000000..8d5210c404
--- /dev/null
+++ b/deps/npm/test/tap/shrinkwrap-lifecycle-cwd.js
@@ -0,0 +1,89 @@
+'use strict'
+var path = require('path')
+var test = require('tap').test
+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'))
+var testdir = path.join(basedir, 'testdir')
+var cachedir = path.join(basedir, '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,
+ env: extend({
+ npm_config_cache: cachedir,
+ npm_config_tmp: tmpdir,
+ npm_config_prefix: globaldir,
+ npm_config_registry: common.registry,
+ npm_config_loglevel: 'warn'
+ }, process.env)
+}
+
+var server
+var fixture = new Tacks(Dir({
+ cache: Dir(),
+ global: Dir(),
+ tmp: Dir(),
+ testdir: Dir({
+ node_modules: Dir({}),
+ 'package.json': File({
+ name: '13252',
+ version: '1.0.0',
+ scripts: {
+ // 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'
+ }
+ }),
+ scripts: Dir({
+ 'shrinkwrap.js': File(
+ 'console.log("OK " + process.cwd())'
+ )
+ })
+ })
+}))
+
+function setup () {
+ cleanup()
+ fixture.create(basedir)
+}
+
+function cleanup () {
+ fixture.remove(basedir)
+}
+
+test('setup', function (t) {
+ setup()
+ mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
+ if (err) throw err
+ server = s
+ t.done()
+ })
+})
+
+test('shrinkwrap-lifecycle-cwd', function (t) {
+ common.npm(['run', 'abc'], conf, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ t.comment(stdout.trim())
+ t.comment(stderr.trim())
+ t.match(stdout.trim(), 'OK ' + testdir, 'got output from lifecycle script')
+ t.is(stderr.trim().length, 0, 'no errors')
+ t.done()
+ })
+})
+
+test('cleanup', function (t) {
+ server.close()
+ cleanup()
+ t.done()
+})
diff --git a/deps/npm/test/tap/tagged-version-matching.js b/deps/npm/test/tap/tagged-version-matching.js
new file mode 100644
index 0000000000..f7d51d90b7
--- /dev/null
+++ b/deps/npm/test/tap/tagged-version-matching.js
@@ -0,0 +1,162 @@
+'use strict'
+var path = require('path')
+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'))
+var testdir = path.join(basedir, 'testdir')
+var cachedir = path.join(basedir, 'cache')
+var globaldir = path.join(basedir, 'global')
+var tmpdir = path.join(basedir, 'tmp')
+
+var conf = {
+ cwd: testdir,
+ env: extend({
+ npm_config_cache: cachedir,
+ npm_config_tmp: tmpdir,
+ npm_config_prefix: globaldir,
+ npm_config_registry: common.registry,
+ npm_config_loglevel: 'warn'
+ }, process.env)
+}
+
+var fixture = new Tacks(Dir({
+ cache: Dir(),
+ global: Dir(),
+ tmp: Dir(),
+ testdir: Dir({
+ node_modules: Dir({
+ example: Dir({
+ 'package.json': File({
+ _from: 'example',
+ _id: 'example@1.0.0',
+ _requested: {
+ raw: 'example@file:example',
+ scope: null,
+ escapedName: 'example',
+ name: 'example',
+ rawSpec: 'file:example',
+ type: 'directory'
+ },
+ dependencies: {
+ tagdep: 'latest',
+ gitdep: 'npm/example-gitdep'
+ },
+ name: 'example',
+ version: '1.0.0'
+ })
+ }),
+ gitdep: Dir({
+ 'package.json': File({
+ _from: 'npm/example-gitdep',
+ _id: 'gitdep@1.0.0',
+ _requested: {
+ raw: 'gitdep@git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ scope: null,
+ escapedName: 'gitdep',
+ name: 'gitdep',
+ rawSpec: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ spec: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ type: 'hosted',
+ hosted: {
+ type: 'github',
+ ssh: 'git@github.com:npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ sshUrl: 'git+ssh://git@github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ httpsUrl: 'git+https://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ gitUrl: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ shortcut: 'github:npm/example-gitdep#da39a3ee5e6b4b0d3255bfef95601890afd80709',
+ directUrl: 'https://raw.githubusercontent.com/npm/example-gitdep/da39a3ee5e6b4b0d3255bfef95601890afd80709/package.json'
+ }
+ },
+ name: 'gitdep',
+ version: '1.0.0'
+ })
+ }),
+ tagdep: Dir({
+ 'package.json': File({
+ _from: 'tagdep@latest',
+ _id: 'tagdep@1.0.0',
+ _requested: {
+ raw: 'tagdep@https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
+ scope: null,
+ escapedName: 'tagdep',
+ name: 'tagdep',
+ rawSpec: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
+ spec: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz',
+ type: 'remote'
+ },
+ name: 'tagdep',
+ version: '1.0.0'
+ })
+ })
+ }),
+ 'npm-shrinkwrap.json': File({
+ name: 'tagged-version-matching',
+ version: '1.0.0',
+ dependencies: {
+ tagdep: {
+ version: '1.0.0',
+ from: 'tagdep@latest',
+ resolved: 'https://registry.example.com/tagdep/-/tagdep-1.0.0.tgz'
+ },
+ example: {
+ version: '1.0.0',
+ from: 'example'
+ },
+ gitdep: {
+ version: '1.0.0',
+ from: 'npm/example-gitdep',
+ resolved: 'git://github.com/npm/example-gitdep.git#da39a3ee5e6b4b0d3255bfef95601890afd80709'
+ }
+ }
+ }),
+ 'package.json': File({
+ name: 'tagged-version-matching',
+ version: '1.0.0',
+ dependencies: {
+ example: 'file:example',
+ gitdep: 'npm/example-gitdep'
+ }
+ })
+ })
+}))
+
+function setup () {
+ cleanup()
+ fixture.create(basedir)
+}
+
+function cleanup () {
+ fixture.remove(basedir)
+}
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('tagged-version-matching', function (t) {
+ common.npm(['ls', '--json'], conf, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stderr.trim()) t.comment(stderr.trim())
+ var result = JSON.parse(stdout.trim())
+ var problems = result.problems || []
+ // Original PR: https://github.com/npm/npm/pull/13941
+ // Original issue: https://github.com/npm/npm/issues/13496
+ // Original issue: https://github.com/npm/npm/issues/11736
+ t.is(problems.length, 0, 'no problems')
+ t.ok(!problems.some(function (err) { return /missing: tagdep/.test(err) }), 'tagged dependency matched ok')
+ t.ok(!problems.some(function (err) { return /missing: gitdep/.test(err) }), 'git dependency matched ok')
+ t.done()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
diff --git a/deps/npm/test/tap/upgrade-lifecycles.js b/deps/npm/test/tap/upgrade-lifecycles.js
new file mode 100644
index 0000000000..f15fe0038e
--- /dev/null
+++ b/deps/npm/test/tap/upgrade-lifecycles.js
@@ -0,0 +1,89 @@
+'use strict'
+var path = require('path')
+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'))
+var testdir = path.join(basedir, 'testdir')
+var cachedir = path.join(basedir, 'cache')
+var globaldir = path.join(basedir, 'global')
+var tmpdir = path.join(basedir, 'tmp')
+
+var conf = {
+ cwd: testdir,
+ env: extend({
+ npm_config_cache: cachedir,
+ npm_config_tmp: tmpdir,
+ npm_config_prefix: globaldir,
+ npm_config_registry: common.registry,
+ npm_config_loglevel: 'warn'
+ }, process.env)
+}
+
+var cycler = {
+ name: 'cycler',
+ version: '1.0.0',
+ scripts: {
+ uninstall: 'echo #UNINSTALL#',
+ install: 'echo #INSTALL#'
+ }
+}
+
+var fixture = new Tacks(Dir({
+ cache: Dir(),
+ global: Dir(),
+ tmp: Dir(),
+ testdir: Dir({
+ 'cycler': Dir({
+ 'package.json': File(cycler)
+ }),
+ node_modules: Dir({
+ 'cycler': Dir({
+ 'package.json': File(cycler)
+ })
+ }),
+ 'package.json': File({
+ name: 'upgrade-lifecycles',
+ version: '1.0.0',
+ dependencies: {
+ 'cycler': 'file:cycler'
+ }
+ })
+ })
+}))
+
+function setup () {
+ cleanup()
+ fixture.create(basedir)
+}
+
+function cleanup () {
+ fixture.remove(basedir)
+}
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('upgrade-lifecycles', function (t) {
+ common.npm(['install', 'file:cycler'], conf, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+
+ t.comment(stdout.trim())
+ t.comment(stderr.trim())
+ t.match(stdout, /#INSTALL#/, 'ran install lifecycle')
+ t.match(stdout, /#UNINSTALL#/, 'ran uninstall lifecycle')
+ t.done()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
diff --git a/deps/npm/test/tap/version-sub-directory-shrinkwrap.js b/deps/npm/test/tap/version-sub-directory-shrinkwrap.js
new file mode 100644
index 0000000000..0455b62ab7
--- /dev/null
+++ b/deps/npm/test/tap/version-sub-directory-shrinkwrap.js
@@ -0,0 +1,80 @@
+var common = require('../common-tap.js')
+var fs = require('fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var npm = require('../../lib/npm.js')
+
+var pkg = path.resolve(__dirname, 'version-sub-directory')
+var subDirectory = path.resolve(pkg, 'sub-directory')
+var packagePath = path.resolve(pkg, 'package.json')
+var shrinkwrapPath = path.resolve(pkg, 'npm-shrinkwrap.json')
+var cache = path.resolve(pkg, 'cache')
+
+var json = { name: 'cat', version: '0.1.2' }
+
+test('npm version <semver> from a subdirectory', function (t) {
+ setup()
+ npmLoad()
+
+ function npmLoad () {
+ npm.load({ cache: cache }, function () {
+ common.makeGitRepo({
+ path: pkg,
+ added: ['package.json', 'npm-shrinkwrap.json']
+ }, version)
+ })
+ }
+
+ function version (er, stdout, stderr) {
+ t.ifError(er, 'git repo initialized without issue')
+ t.notOk(stderr, 'no error output')
+ npm.config.set('sign-git-tag', false)
+ npm.commands.version(['patch'], checkVersion)
+ }
+
+ function checkVersion (er) {
+ var newShrinkwrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
+ t.is(newShrinkwrap.version, '0.1.3', 'shrinkwrap has right version')
+ var newPackage = JSON.parse(fs.readFileSync(packagePath))
+ t.is(newPackage.version, '0.1.3', 'package.json has right version')
+ var git = require('../../lib/utils/git.js')
+ t.ifError(er, 'version command ran without error')
+ git.whichAndExec(
+ ['log'],
+ { cwd: pkg, env: process.env },
+ checkCommit
+ )
+ }
+
+ function checkCommit (er, log, stderr) {
+ t.ifError(er, 'git log ran without issue')
+ t.notOk(stderr, 'no error output')
+ t.ok(log.match(/0\.1\.3/g), 'commited from subdirectory')
+ t.end()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ // windows fix for locked files
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+}
+
+function setup () {
+ cleanup()
+ mkdirp.sync(cache)
+ mkdirp.sync(subDirectory)
+ process.chdir(subDirectory)
+ fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
+ fs.writeFileSync(shrinkwrapPath, JSON.stringify(json), 'utf8')
+}
diff --git a/deps/npm/test/tap/view.js b/deps/npm/test/tap/view.js
index e80031b1c2..371e1d922d 100644
--- a/deps/npm/test/tap/view.js
+++ b/deps/npm/test/tap/view.js
@@ -11,6 +11,8 @@ var t2dir = path.resolve(tmp, 'view-local-notmine')
var t3dir = path.resolve(tmp, 'view-local-mine')
var mr = require('npm-registry-mock')
+var server
+
test('setup', function (t) {
mkdirp.sync(t1dir)
mkdirp.sync(t2dir)
@@ -29,7 +31,11 @@ test('setup', function (t) {
}), 'utf8')
t.pass('created fixtures')
- t.end()
+
+ mr({ port: common.port, plugin: plugin }, function (er, s) {
+ server = s
+ t.end()
+ })
})
function plugin (server) {
@@ -84,294 +90,293 @@ test('npm view . with no package.json', function (t) {
test('npm view . with no published package', function (t) {
process.chdir(t3dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry
- ], { cwd: t3dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
- t.similar(stderr, /version not found/m)
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.',
+ '--registry=' + common.registry
+ ], { cwd: t3dir }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 1, 'exit not ok')
+ t.similar(stderr, /version not found/m)
+ t.end()
})
})
test('npm view .', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- var re = new RegExp("name: 'test-repo-url-https'")
- t.similar(stdout, re)
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ var re = new RegExp("name: 'test-repo-url-https'")
+ t.similar(stdout, re)
+ t.end()
})
})
test('npm view . select fields', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.',
- 'main',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), 'index.js', 'should print `index.js`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.',
+ 'main',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), 'index.js', 'should print `index.js`')
+ t.end()
})
})
test('npm view .@<version>', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'version',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '0.0.0', 'should print `0.0.0`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.@0.0.0',
+ 'version',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), '0.0.0', 'should print `0.0.0`')
+ t.end()
})
})
test('npm view .@<version> version --json', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), '"0.0.0"', 'should print `"0.0.0"`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.@0.0.0',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), '"0.0.0"', 'should print `"0.0.0"`')
+ t.end()
})
})
test('npm view . --json author name version', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.',
- 'author',
- 'name',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- var expected = JSON.stringify({
- author: 'Evan Lucas <evanlucas@me.com>',
- name: 'test-repo-url-https',
- version: '0.0.1'
- }, null, 2)
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), expected, 'should print ' + expected)
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.',
+ 'author',
+ 'name',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ var expected = JSON.stringify({
+ author: 'Evan Lucas <evanlucas@me.com>',
+ name: 'test-repo-url-https',
+ version: '0.0.1'
+ }, null, 2)
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), expected, 'should print ' + expected)
+ t.end()
})
})
test('npm view .@<version> --json author name version', function (t) {
process.chdir(t2dir)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- '.@0.0.0',
- 'author',
- 'name',
- 'version',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- var expected = JSON.stringify({
- author: 'Evan Lucas <evanlucas@me.com>',
- name: 'test-repo-url-https',
- version: '0.0.0'
- }, null, 2)
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), expected, 'should print ' + expected)
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ '.@0.0.0',
+ 'author',
+ 'name',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ var expected = JSON.stringify({
+ author: 'Evan Lucas <evanlucas@me.com>',
+ name: 'test-repo-url-https',
+ version: '0.0.0'
+ }, null, 2)
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), expected, 'should print ' + expected)
+ t.end()
})
})
test('npm view <package name>', function (t) {
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- 'underscore',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- var re = new RegExp("name: 'underscore'")
- t.similar(stdout, re, 'should have name `underscore`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ 'underscore',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ var re = new RegExp("name: 'underscore'")
+ t.similar(stdout, re, 'should have name `underscore`')
+ t.end()
})
})
test('npm view <package name> --global', function (t) {
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- 'underscore',
- '--global',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- var re = new RegExp("name: 'underscore'")
- t.similar(stdout, re, 'should have name `underscore`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ 'underscore',
+ '--global',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ var re = new RegExp("name: 'underscore'")
+ t.similar(stdout, re, 'should have name `underscore`')
+ t.end()
})
})
test('npm view <package name>@<semver range> versions', function (t) {
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- 'underscore@^1.5.0',
- 'versions',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- var re = new RegExp('1.5.0')
- t.similar(stdout, re, 'should have version `1.5.0`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ 'underscore@^1.5.0',
+ 'versions',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ var re = new RegExp('1.5.0')
+ t.similar(stdout, re, 'should have version `1.5.0`')
+ t.end()
+ })
+})
+
+test('npm view <package name>@<semver range> version --json', function (t) {
+ common.npm([
+ 'view',
+ 'underscore@~1.5.0',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), JSON.stringify([
+ '1.5.0',
+ '1.5.1'
+ ], null, 2), 'should have three versions')
+ t.end()
})
})
test('npm view <package name> --json', function (t) {
t.plan(3)
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- 'underscore',
- '--json',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- s.close()
- try {
- var out = JSON.parse(stdout.trim())
- t.similar(out, {
- maintainers: ['jashkenas <jashkenas@gmail.com>']
- }, 'should have the same maintainer')
- } catch (er) {
- t.fail('Unable to parse JSON')
- }
- })
+ common.npm([
+ 'view',
+ 'underscore',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ try {
+ var out = JSON.parse(stdout.trim())
+ t.similar(out, {
+ maintainers: ['jashkenas <jashkenas@gmail.com>']
+ }, 'should have the same maintainer')
+ } catch (er) {
+ t.fail('Unable to parse JSON')
+ }
+ })
+})
+
+test('npm view <package name>@<invalid version>', function (t) {
+ common.npm([
+ 'view',
+ 'underscore@12345',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), '', 'should return empty')
+ t.end()
+ })
+})
+
+test('npm view <package name>@<invalid version> --json', function (t) {
+ common.npm([
+ 'view',
+ 'underscore@12345',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), '', 'should return empty')
+ t.end()
})
})
test('npm view <package name> <field>', function (t) {
- mr({ port: common.port, plugin: plugin }, function (er, s) {
- common.npm([
- 'view',
- 'underscore',
- 'homepage',
- '--registry=' + common.registry
- ], { cwd: t2dir }, function (err, code, stdout) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 0, 'exit ok')
- t.equal(stdout.trim(), 'http://underscorejs.org',
- 'homepage should equal `http://underscorejs.org`')
- s.close()
- t.end()
- })
+ common.npm([
+ 'view',
+ 'underscore',
+ 'homepage',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), 'http://underscorejs.org',
+ 'homepage should equal `http://underscorejs.org`')
+ t.end()
})
})
test('npm view with invalid package name', function (t) {
var invalidName = 'InvalidPackage'
- var obj = {}
- obj['/' + invalidName] = [404, {'error': 'not found'}]
-
- mr({ port: common.port, mocks: { 'get': obj } }, function (er, s) {
- common.npm([
- 'view',
- invalidName,
- '--registry=' + common.registry
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
-
- t.similar(stderr, new RegExp('is not in the npm registry'),
- 'Package should NOT be found')
-
- t.dissimilar(stderr, new RegExp('use the name yourself!'),
- 'Suggestion should not be there')
-
- t.similar(stderr, new RegExp('name can no longer contain capital letters'),
- 'Suggestion about Capital letter should be there')
-
- s.close()
- t.end()
- })
+
+ server.get('/' + invalidName).reply('404', {'error': 'not found'})
+ common.npm([
+ 'view',
+ invalidName,
+ '--registry=' + common.registry
+ ], {}, function (err, code, stdout, stderr) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 1, 'exit not ok')
+
+ t.similar(stderr, new RegExp('is not in the npm registry'),
+ 'Package should NOT be found')
+
+ t.dissimilar(stderr, new RegExp('use the name yourself!'),
+ 'Suggestion should not be there')
+
+ t.similar(stderr, new RegExp('name can no longer contain capital letters'),
+ 'Suggestion about Capital letter should be there')
+
+ t.end()
})
})
test('npm view with valid but non existent package name', function (t) {
- mr({ port: common.port, mocks: {
- 'get': {
- '/valid-but-non-existent-package': [404, {'error': 'not found'}]
- }
- }}, function (er, s) {
- common.npm([
- 'view',
- 'valid-but-non-existent-package',
- '--registry=' + common.registry
- ], {}, function (err, code, stdout, stderr) {
- t.ifError(err, 'view command finished successfully')
- t.equal(code, 1, 'exit not ok')
-
- t.similar(stderr,
- 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!'),
- 'Suggestion should be there')
-
- s.close()
- t.end()
- })
+ server.get('/valid-but-non-existent-package').reply(404, {'error': 'not found'})
+ common.npm([
+ 'view',
+ 'valid-but-non-existent-package',
+ '--registry=' + common.registry
+ ], {}, function (err, code, stdout, stderr) {
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 1, 'exit not ok')
+
+ t.similar(stderr,
+ 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!'),
+ 'Suggestion should be there')
+
+ t.end()
})
})
@@ -381,5 +386,6 @@ test('cleanup', function (t) {
rimraf.sync(t2dir)
rimraf.sync(t3dir)
t.pass('cleaned up')
+ server.close()
t.end()
})