summaryrefslogtreecommitdiff
path: root/deps/npm/test
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test')
-rw-r--r--deps/npm/test/common-tap.js57
-rw-r--r--deps/npm/test/fixtures/config/userconfig-with-gc22
-rw-r--r--deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js (renamed from deps/npm/test/tap/add-remote-git-get-resolved.js)12
-rw-r--r--deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js (renamed from deps/npm/test/tap/git-races.js)0
-rw-r--r--deps/npm/test/need-npm5-update/ignore-shrinkwrap.js (renamed from deps/npm/test/tap/ignore-shrinkwrap.js)0
-rw-r--r--deps/npm/test/need-npm5-update/legacy-array-bin.js (renamed from deps/npm/test/tap/legacy-array-bin.js)0
-rw-r--r--deps/npm/test/need-npm5-update/legacy-dir-bin.js (renamed from deps/npm/test/tap/legacy-dir-bin.js)0
-rw-r--r--deps/npm/test/need-npm5-update/legacy-npm-self-install.js (renamed from deps/npm/test/tap/legacy-npm-self-install.js)1
-rw-r--r--deps/npm/test/need-npm5-update/legacy-optional-deps.js (renamed from deps/npm/test/tap/legacy-optional-deps.js)0
-rw-r--r--deps/npm/test/need-npm5-update/legacy-shrinkwrap.js (renamed from deps/npm/test/network/legacy-shrinkwrap.js)0
-rw-r--r--deps/npm/test/need-npm5-update/lifecycle-signal.js (renamed from deps/npm/test/tap/lifecycle-signal.js)0
-rw-r--r--deps/npm/test/need-npm5-update/move-no-clobber-dest-node-modules.js (renamed from deps/npm/test/tap/move-no-clobber-dest-node-modules.js)0
-rw-r--r--deps/npm/test/need-npm5-update/need-only-update-save-optional/update-save.js (renamed from deps/npm/test/tap/update-save.js)0
-rw-r--r--deps/npm/test/need-npm5-update/need-outdated/update-symlink.js (renamed from deps/npm/test/tap/update-symlink.js)22
-rw-r--r--deps/npm/test/need-npm5-update/outdated-depth-deep.js (renamed from deps/npm/test/tap/outdated-depth-deep.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-depth-integer.js (renamed from deps/npm/test/tap/outdated-depth-integer.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-include-devdependencies.js (renamed from deps/npm/test/tap/outdated-include-devdependencies.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-local.js (renamed from deps/npm/test/tap/outdated-local.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-new-versions.js (renamed from deps/npm/test/tap/outdated-new-versions.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-notarget.js (renamed from deps/npm/test/tap/outdated-notarget.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-private.js (renamed from deps/npm/test/tap/outdated-private.js)0
-rw-r--r--deps/npm/test/need-npm5-update/outdated-symlink.js (renamed from deps/npm/test/tap/outdated-symlink.js)0
-rw-r--r--deps/npm/test/need-npm5-update/peer-deps-invalid.js (renamed from deps/npm/test/tap/peer-deps-invalid.js)0
-rw-r--r--deps/npm/test/need-npm5-update/peer-deps-toplevel.js (renamed from deps/npm/test/tap/peer-deps-toplevel.js)3
-rw-r--r--deps/npm/test/need-npm5-update/peer-deps-without-package-json.js (renamed from deps/npm/test/tap/peer-deps-without-package-json.js)0
-rw-r--r--deps/npm/test/need-npm5-update/rm-linked.js (renamed from deps/npm/test/tap/rm-linked.js)0
-rw-r--r--deps/npm/test/need-npm5-update/shrinkwrap-complete-except-dev.js (renamed from deps/npm/test/tap/shrinkwrap-complete-except-dev.js)0
-rw-r--r--deps/npm/test/need-npm5-update/shrinkwrap-dev-dep-cycle.js (renamed from deps/npm/test/tap/shrinkwrap-dev-dep-cycle.js)11
-rw-r--r--deps/npm/test/tap/404-parent.js14
-rw-r--r--deps/npm/test/tap/404-private-registry-scoped.js2
-rw-r--r--deps/npm/test/tap/add-local.js137
-rw-r--r--deps/npm/test/tap/add-named-update-protocol-port.js1
-rw-r--r--deps/npm/test/tap/add-remote-git-fake-windows.js132
-rw-r--r--deps/npm/test/tap/add-remote-git-file.js11
-rw-r--r--deps/npm/test/tap/add-remote-git-shrinkwrap.js26
-rw-r--r--deps/npm/test/tap/anon-cli-metrics.js27
-rw-r--r--deps/npm/test/tap/bearer-token-check.js14
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds-package.js18
-rw-r--r--deps/npm/test/tap/bitbucket-https-url-with-creds.js18
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut-package.js20
-rw-r--r--deps/npm/test/tap/bitbucket-shortcut.js20
-rw-r--r--deps/npm/test/tap/bundled-dependencies-no-pkgjson.js18
-rw-r--r--deps/npm/test/tap/bundled-dependencies-nonarray.js32
-rw-r--r--deps/npm/test/tap/cache-add-localdir-fallback.js84
-rw-r--r--deps/npm/test/tap/cache-ls-filenames.js51
-rw-r--r--deps/npm/test/tap/cache-shasum-fork.js13
-rw-r--r--deps/npm/test/tap/cache-shasum.js50
-rw-r--r--deps/npm/test/tap/config-meta.js2
-rw-r--r--deps/npm/test/tap/dedupe-scoped.js28
-rw-r--r--deps/npm/test/tap/dedupe.js1
-rw-r--r--deps/npm/test/tap/doctor.js78
-rw-r--r--deps/npm/test/tap/fetch-package-metadata.js15
-rw-r--r--deps/npm/test/tap/files-and-ignores.js7
-rw-r--r--deps/npm/test/tap/full-warning-messages.js14
-rw-r--r--deps/npm/test/tap/gently-rm-overeager.js14
-rw-r--r--deps/npm/test/tap/gently-rm-symlinked-global-dir.js26
-rw-r--r--deps/npm/test/tap/get.js25
-rw-r--r--deps/npm/test/tap/gist-short-shortcut-package.js4
-rw-r--r--deps/npm/test/tap/gist-short-shortcut.js2
-rw-r--r--deps/npm/test/tap/gist-shortcut-package.js2
-rw-r--r--deps/npm/test/tap/gist-shortcut.js2
-rw-r--r--deps/npm/test/tap/git-npmignore.js13
-rw-r--r--deps/npm/test/tap/git-prepare.js181
-rw-r--r--deps/npm/test/tap/github-shortcut-package.js2
-rw-r--r--deps/npm/test/tap/github-shortcut.js49
-rw-r--r--deps/npm/test/tap/gitlab-shortcut-package.js2
-rw-r--r--deps/npm/test/tap/gitlab-shortcut.js2
-rw-r--r--deps/npm/test/tap/install-actions.js12
-rw-r--r--deps/npm/test/tap/install-at-locally.js6
-rw-r--r--deps/npm/test/tap/install-noargs-dev.js2
-rw-r--r--deps/npm/test/tap/install-report-just-installed.js7
-rw-r--r--deps/npm/test/tap/install-save-local.js4
-rw-r--r--deps/npm/test/tap/install-shrinkwrapped-git.js2
-rw-r--r--deps/npm/test/tap/it.js2
-rw-r--r--deps/npm/test/tap/ls-depth-cli.js107
-rw-r--r--deps/npm/test/tap/ls-depth-unmet.js2
-rw-r--r--deps/npm/test/tap/ls-l-depth-0.js31
-rw-r--r--deps/npm/test/tap/optional-metadep-rollback-collision.js1
-rw-r--r--deps/npm/test/tap/outdated-long.js3
-rw-r--r--deps/npm/test/tap/override-bundled.js65
-rw-r--r--deps/npm/test/tap/owner.js42
-rw-r--r--deps/npm/test/tap/prepublish.js2
-rw-r--r--deps/npm/test/tap/prune.js26
-rw-r--r--deps/npm/test/tap/retry-on-stale-cache.js10
-rw-r--r--deps/npm/test/tap/search.js2
-rw-r--r--deps/npm/test/tap/shared-linked.js11
-rw-r--r--deps/npm/test/tap/shrinkwrap-default-arg-ver.js104
-rw-r--r--deps/npm/test/tap/shrinkwrap-default-dev.js35
-rw-r--r--deps/npm/test/tap/shrinkwrap-dev-dependency.js10
-rw-r--r--deps/npm/test/tap/shrinkwrap-empty-deps.js33
-rw-r--r--deps/npm/test/tap/shrinkwrap-extra-metadata.js81
-rw-r--r--deps/npm/test/tap/shrinkwrap-lifecycle.js9
-rw-r--r--deps/npm/test/tap/shrinkwrap-local-dependency.js15
-rw-r--r--deps/npm/test/tap/shrinkwrap-nested.js58
-rw-r--r--deps/npm/test/tap/shrinkwrap-optional-dependency.js6
-rw-r--r--deps/npm/test/tap/shrinkwrap-optional-property.js10
-rw-r--r--deps/npm/test/tap/shrinkwrap-package-integrity.js50
-rw-r--r--deps/npm/test/tap/shrinkwrap-prod-dependency-also.js14
-rw-r--r--deps/npm/test/tap/shrinkwrap-prod-dependency.js10
-rw-r--r--deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js4
-rw-r--r--deps/npm/test/tap/shrinkwrap-save-dev-without-existing-dev-deps.js87
-rw-r--r--deps/npm/test/tap/shrinkwrap-scoped-auth.js10
-rw-r--r--deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js104
-rw-r--r--deps/npm/test/tap/shrinkwrap-transitive-dev.js83
-rw-r--r--deps/npm/test/tap/spawn-enoent.js2
-rw-r--r--deps/npm/test/tap/spec-local-specifiers.js630
-rw-r--r--deps/npm/test/tap/splat-with-only-prerelease-to-latest.js96
-rw-r--r--deps/npm/test/tap/tagged-version-matching.js65
-rw-r--r--deps/npm/test/tap/tree-style.js19
-rw-r--r--deps/npm/test/tap/uninstall-link-clean.js6
-rw-r--r--deps/npm/test/tap/uninstall-package.js15
-rw-r--r--deps/npm/test/tap/uninstall-save.js4
-rw-r--r--deps/npm/test/tap/unit-deps-childDependencySpecifier.js59
-rw-r--r--deps/npm/test/tap/unit-deps-earliestInstallable.js51
-rw-r--r--deps/npm/test/tap/unpublish-config.js2
-rw-r--r--deps/npm/test/tap/url-dependencies.js2
-rw-r--r--deps/npm/test/tap/version-allow-same-version.js65
-rw-r--r--deps/npm/test/tap/version-from-git.js2
118 files changed, 1879 insertions, 1484 deletions
diff --git a/deps/npm/test/common-tap.js b/deps/npm/test/common-tap.js
index 3a9f9d4d28..16475411e1 100644
--- a/deps/npm/test/common-tap.js
+++ b/deps/npm/test/common-tap.js
@@ -3,6 +3,7 @@ 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
if (!global.setImmediate || !require('timers').setImmediate) {
@@ -17,18 +18,21 @@ var path = require('path')
var port = exports.port = 1337
exports.registry = 'http://localhost:' + port
-process.env.npm_config_loglevel = 'error'
-process.env.npm_config_progress = 'false'
+const ourenv = {}
+ourenv.npm_config_loglevel = 'error'
+ourenv.npm_config_progress = 'false'
var npm_config_cache = path.resolve(__dirname, 'npm_cache')
-process.env.npm_config_cache = exports.npm_config_cache = npm_config_cache
-process.env.npm_config_userconfig = exports.npm_config_userconfig = path.join(__dirname, 'fixtures', 'config', 'userconfig')
-process.env.npm_config_globalconfig = exports.npm_config_globalconfig = path.join(__dirname, 'fixtures', 'config', 'globalconfig')
-process.env.npm_config_global_style = 'false'
-process.env.npm_config_legacy_bundling = 'false'
-process.env.random_env_var = 'foo'
+ourenv.npm_config_cache = exports.npm_config_cache = npm_config_cache
+ourenv.npm_config_userconfig = exports.npm_config_userconfig = path.join(__dirname, 'fixtures', 'config', 'userconfig')
+ourenv.npm_config_globalconfig = exports.npm_config_globalconfig = path.join(__dirname, 'fixtures', 'config', 'globalconfig')
+ourenv.npm_config_global_style = 'false'
+ourenv.npm_config_legacy_bundling = 'false'
+ourenv.npm_config_fetch_retries = '0'
+ourenv.random_env_var = 'foo'
// suppress warnings about using a prerelease version of node
-process.env.npm_config_node_version = process.version.replace(/-.*$/, '')
+ourenv.npm_config_node_version = process.version.replace(/-.*$/, '')
+for (let key of Object.keys(ourenv)) process.env[key] = ourenv[key]
var bin = exports.bin = require.resolve('../bin/npm-cli.js')
@@ -38,12 +42,20 @@ var once = require('once')
var nodeBin = exports.nodeBin = process.env.npm_node_execpath || process.env.NODE || process.execPath
exports.npm = function (cmd, opts, cb) {
+ if (!cb) {
+ var prom = new Bluebird((resolve, reject) => {
+ cb = function (err, code, stdout, stderr) {
+ if (err) return reject(err)
+ return resolve([code, stdout, stderr])
+ }
+ })
+ }
cb = once(cb)
cmd = [bin].concat(cmd)
- opts = opts || {}
+ opts = extend({}, opts || {})
opts.env = opts.env || process.env
- if (opts.env._storage) opts.env = opts.env._storage
+ if (opts.env._storage) opts.env = Object.assign({}, opts.env._storage)
if (!opts.env.npm_config_cache) {
opts.env.npm_config_cache = npm_config_cache
}
@@ -74,7 +86,7 @@ exports.npm = function (cmd, opts, cb) {
child.on('close', function (code) {
cb(null, code, stdout, stderr)
})
- return child
+ return prom || child
}
exports.makeGitRepo = function (params, cb) {
@@ -131,8 +143,23 @@ exports.newEnv = function () {
return new Environment(process.env)
}
+exports.emptyEnv = function () {
+ const filtered = {}
+ for (let key of Object.keys(process.env)) {
+ if (!/^npm_/.test(key)) filtered[key] = process.env[key]
+ }
+ for (let key of Object.keys(ourenv)) {
+ filtered[key] = ourenv[key]
+ }
+ return new Environment(filtered)
+}
+
function Environment (env) {
- this._storage = extend({}, env)
+ if (env instanceof Environment) return env.clone()
+
+ Object.defineProperty(this, '_storage', {
+ value: extend({}, env)
+ })
}
Environment.prototype = {}
@@ -150,7 +177,7 @@ Environment.prototype.clone = function () {
}
Environment.prototype.extend = function (env) {
- var self = this
+ var self = this.clone()
var args = Array.isArray(env) ? env : arguments
var ii
for (ii = 0; ii < args.length; ++ii) {
@@ -160,5 +187,5 @@ Environment.prototype.extend = function (env) {
self._storage[name] = arg[name]
})
}
- return this
+ return self
}
diff --git a/deps/npm/test/fixtures/config/userconfig-with-gc b/deps/npm/test/fixtures/config/userconfig-with-gc
new file mode 100644
index 0000000000..62ad80be11
--- /dev/null
+++ b/deps/npm/test/fixtures/config/userconfig-with-gc
@@ -0,0 +1,22 @@
+globalconfig=/Users/zkat/Documents/code/npm/test/fixtures/config/globalconfig
+email=i@izs.me
+env-thing=asdf
+init.author.name=Isaac Z. Schlueter
+init.author.email=i@izs.me
+init.author.url=http://blog.izs.me/
+init.version=1.2.3
+proprietary-attribs=false
+npm:publishtest=true
+_npmjs.org:couch=https://admin:password@localhost:5984/registry
+npm-www:nocache=1
+sign-git-tag=false
+message=v%s
+strict-ssl=false
+_auth="dXNlcm5hbWU6cGFzc3dvcmQ="
+
+[_token]
+AuthSession=yabba-dabba-doodle
+version=1
+expires=1345001053415
+path=/
+httponly=true
diff --git a/deps/npm/test/tap/add-remote-git-get-resolved.js b/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js
index dab51d16ef..77463e8bea 100644
--- a/deps/npm/test/tap/add-remote-git-get-resolved.js
+++ b/deps/npm/test/need-npm5-update/belongs-in-pacote/add-remote-git-get-resolved.js
@@ -3,8 +3,8 @@ var test = require('tap').test
var npm = require('../../lib/npm.js')
var common = require('../common-tap.js')
+var npa = require('npm-package-arg')
-var normalizeGitUrl = require('normalize-git-url')
var getResolved = null
/**
@@ -12,7 +12,7 @@ var getResolved = null
* before getResolved is, and receives *that* URL.
*/
function tryGetResolved (uri, treeish) {
- return getResolved(normalizeGitUrl(uri).url, treeish)
+ return getResolved(npa(uri), uri, treeish)
}
test('setup', function (t) {
@@ -45,8 +45,8 @@ test('add-remote-git#get-resolved git: passthru', function (t) {
test('add-remote-git#get-resolved SSH', function (t) {
t.comment('tests for https://github.com/npm/npm/issues/7961')
- verify('git@github.com:foo/repo')
- verify('git@github.com:foo/repo#master')
+ verify('git+ssh://git@github.com:foo/repo')
+ verify('git+ssh://git@github.com:foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#master')
verify('git+ssh://git@github.com/foo/repo#decadacefadabade')
@@ -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',
@@ -124,6 +124,6 @@ test('add-remote-git#get-resolved edge cases', function (t) {
'git://gitbub.com/foo/bar.git#decadacefadabade',
'don\'t break non-hosted git: URLs'
)
-
+*/
t.end()
})
diff --git a/deps/npm/test/tap/git-races.js b/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js
index c6c27d5040..c6c27d5040 100644
--- a/deps/npm/test/tap/git-races.js
+++ b/deps/npm/test/need-npm5-update/belongs-in-pacote/git-races.js
diff --git a/deps/npm/test/tap/ignore-shrinkwrap.js b/deps/npm/test/need-npm5-update/ignore-shrinkwrap.js
index 9468162eee..9468162eee 100644
--- a/deps/npm/test/tap/ignore-shrinkwrap.js
+++ b/deps/npm/test/need-npm5-update/ignore-shrinkwrap.js
diff --git a/deps/npm/test/tap/legacy-array-bin.js b/deps/npm/test/need-npm5-update/legacy-array-bin.js
index 3e421ee23e..3e421ee23e 100644
--- a/deps/npm/test/tap/legacy-array-bin.js
+++ b/deps/npm/test/need-npm5-update/legacy-array-bin.js
diff --git a/deps/npm/test/tap/legacy-dir-bin.js b/deps/npm/test/need-npm5-update/legacy-dir-bin.js
index e9e6bdfe13..e9e6bdfe13 100644
--- a/deps/npm/test/tap/legacy-dir-bin.js
+++ b/deps/npm/test/need-npm5-update/legacy-dir-bin.js
diff --git a/deps/npm/test/tap/legacy-npm-self-install.js b/deps/npm/test/need-npm5-update/legacy-npm-self-install.js
index 2051802c2e..d9d1124bda 100644
--- a/deps/npm/test/tap/legacy-npm-self-install.js
+++ b/deps/npm/test/need-npm5-update/legacy-npm-self-install.js
@@ -49,6 +49,7 @@ test('npm-self-install', function (t) {
env.npm_config_user_agent = null
env.npm_config_color = 'always'
env.npm_config_progress = 'always'
+ env.npm_config_shrinkwrap = 'false'
var PATH = env.PATH ? env.PATH.split(pathsep) : []
var binpath = isWin32 ? globalpath : path.join(globalpath, 'bin')
var cmdname = isWin32 ? 'npm.cmd' : 'npm'
diff --git a/deps/npm/test/tap/legacy-optional-deps.js b/deps/npm/test/need-npm5-update/legacy-optional-deps.js
index 08ac98522d..08ac98522d 100644
--- a/deps/npm/test/tap/legacy-optional-deps.js
+++ b/deps/npm/test/need-npm5-update/legacy-optional-deps.js
diff --git a/deps/npm/test/network/legacy-shrinkwrap.js b/deps/npm/test/need-npm5-update/legacy-shrinkwrap.js
index 6f53030377..6f53030377 100644
--- a/deps/npm/test/network/legacy-shrinkwrap.js
+++ b/deps/npm/test/need-npm5-update/legacy-shrinkwrap.js
diff --git a/deps/npm/test/tap/lifecycle-signal.js b/deps/npm/test/need-npm5-update/lifecycle-signal.js
index 065e5a830a..065e5a830a 100644
--- a/deps/npm/test/tap/lifecycle-signal.js
+++ b/deps/npm/test/need-npm5-update/lifecycle-signal.js
diff --git a/deps/npm/test/tap/move-no-clobber-dest-node-modules.js b/deps/npm/test/need-npm5-update/move-no-clobber-dest-node-modules.js
index 4e487837ad..4e487837ad 100644
--- a/deps/npm/test/tap/move-no-clobber-dest-node-modules.js
+++ b/deps/npm/test/need-npm5-update/move-no-clobber-dest-node-modules.js
diff --git a/deps/npm/test/tap/update-save.js b/deps/npm/test/need-npm5-update/need-only-update-save-optional/update-save.js
index f01fa0f542..f01fa0f542 100644
--- a/deps/npm/test/tap/update-save.js
+++ b/deps/npm/test/need-npm5-update/need-only-update-save-optional/update-save.js
diff --git a/deps/npm/test/tap/update-symlink.js b/deps/npm/test/need-npm5-update/need-outdated/update-symlink.js
index 1fb07b8a75..7de80b110d 100644
--- a/deps/npm/test/tap/update-symlink.js
+++ b/deps/npm/test/need-npm5-update/need-outdated/update-symlink.js
@@ -71,23 +71,23 @@ test('setup', function (t) {
})
test('when update is called linked packages should be excluded', function (t) {
- common.npm(['update'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
+ common.npm(['update', '--parseable'], OPTS, function (err, c, out, stderr) {
+ if (err) throw err
t.equal(c, 0)
- t.has(out, /async@0.2.10/, 'updated ok')
+ t.has(out, /^update\tasync\t0.2.10\t/m, 'updated ok')
t.doesNotHave(stderr, /ERR!/, 'no errors in stderr')
t.end()
})
})
test('when install is called and the package already exists as a link, outputs a warning if the requested version is not the same as the linked one', function (t) {
- common.npm(['install', 'underscore'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
+ common.npm(['install', 'underscore', '--parseable'], OPTS, function (err, c, out, stderr) {
+ if (err) throw err
t.equal(c, 0)
t.comment(out.trim())
t.comment(stderr.trim())
- t.doesNotHave(out, /underscore/, 'linked package not updated')
+ t.has(out, /^update-linked\tunderscore\t/m)
t.has(stderr, /underscore/, 'warning output relating to linked package')
t.doesNotHave(stderr, /ERR!/, 'no errors in stderr')
t.end()
@@ -95,12 +95,12 @@ test('when install is called and the package already exists as a link, outputs a
})
test('when install is called and the package already exists as a link, does not warn if the requested version is same as the linked one', function (t) {
- common.npm(['install', 'underscore@1.3.1'], OPTS, function (err, c, out, stderr) {
- t.ifError(err)
+ common.npm(['install', 'underscore@1.3.1', '--parseable'], OPTS, function (err, c, out, stderr) {
+ if (err) throw err
t.equal(c, 0)
t.comment(out.trim())
t.comment(stderr.trim())
- t.doesNotHave(out, /underscore/, 'linked package not updated')
+ t.has(out, /^update-linked\tunderscore\t/m)
t.doesNotHave(stderr, /underscore/, 'no warning or error relating to linked package')
t.doesNotHave(stderr, /ERR!/, 'no errors in stderr')
t.end()
@@ -110,10 +110,10 @@ test('when install is called and the package already exists as a link, does not
test('cleanup', function (t) {
server.close()
common.npm(['rm', 'underscore', 'async'], OPTS, function (err, code) {
- t.ifError(err, 'npm removed the linked package without error')
+ if (err) throw err
t.equal(code, 0, 'cleanup in local ok')
common.npm(['rm', '-g', 'underscore'], OPTS, function (err, code) {
- t.ifError(err, 'npm removed the global package without error')
+ if (err) throw err
t.equal(code, 0, 'cleanup in global ok')
cleanup()
diff --git a/deps/npm/test/tap/outdated-depth-deep.js b/deps/npm/test/need-npm5-update/outdated-depth-deep.js
index 14d4f1faf8..14d4f1faf8 100644
--- a/deps/npm/test/tap/outdated-depth-deep.js
+++ b/deps/npm/test/need-npm5-update/outdated-depth-deep.js
diff --git a/deps/npm/test/tap/outdated-depth-integer.js b/deps/npm/test/need-npm5-update/outdated-depth-integer.js
index 5e743a0a77..5e743a0a77 100644
--- a/deps/npm/test/tap/outdated-depth-integer.js
+++ b/deps/npm/test/need-npm5-update/outdated-depth-integer.js
diff --git a/deps/npm/test/tap/outdated-include-devdependencies.js b/deps/npm/test/need-npm5-update/outdated-include-devdependencies.js
index 331d0b3b33..331d0b3b33 100644
--- a/deps/npm/test/tap/outdated-include-devdependencies.js
+++ b/deps/npm/test/need-npm5-update/outdated-include-devdependencies.js
diff --git a/deps/npm/test/tap/outdated-local.js b/deps/npm/test/need-npm5-update/outdated-local.js
index c253331d07..c253331d07 100644
--- a/deps/npm/test/tap/outdated-local.js
+++ b/deps/npm/test/need-npm5-update/outdated-local.js
diff --git a/deps/npm/test/tap/outdated-new-versions.js b/deps/npm/test/need-npm5-update/outdated-new-versions.js
index bfd63e18c3..bfd63e18c3 100644
--- a/deps/npm/test/tap/outdated-new-versions.js
+++ b/deps/npm/test/need-npm5-update/outdated-new-versions.js
diff --git a/deps/npm/test/tap/outdated-notarget.js b/deps/npm/test/need-npm5-update/outdated-notarget.js
index 14388a80bc..14388a80bc 100644
--- a/deps/npm/test/tap/outdated-notarget.js
+++ b/deps/npm/test/need-npm5-update/outdated-notarget.js
diff --git a/deps/npm/test/tap/outdated-private.js b/deps/npm/test/need-npm5-update/outdated-private.js
index 39bd6f1ac9..39bd6f1ac9 100644
--- a/deps/npm/test/tap/outdated-private.js
+++ b/deps/npm/test/need-npm5-update/outdated-private.js
diff --git a/deps/npm/test/tap/outdated-symlink.js b/deps/npm/test/need-npm5-update/outdated-symlink.js
index a7792f4a31..a7792f4a31 100644
--- a/deps/npm/test/tap/outdated-symlink.js
+++ b/deps/npm/test/need-npm5-update/outdated-symlink.js
diff --git a/deps/npm/test/tap/peer-deps-invalid.js b/deps/npm/test/need-npm5-update/peer-deps-invalid.js
index 39ad612e5a..39ad612e5a 100644
--- a/deps/npm/test/tap/peer-deps-invalid.js
+++ b/deps/npm/test/need-npm5-update/peer-deps-invalid.js
diff --git a/deps/npm/test/tap/peer-deps-toplevel.js b/deps/npm/test/need-npm5-update/peer-deps-toplevel.js
index a4384a7a55..e2285e7699 100644
--- a/deps/npm/test/tap/peer-deps-toplevel.js
+++ b/deps/npm/test/need-npm5-update/peer-deps-toplevel.js
@@ -35,12 +35,10 @@ var expected = {
dependencies: {
'npm-test-peer-deps': {
version: '0.0.0',
- from: 'npm-test-peer-deps@*',
resolved: common.registry + '/npm-test-peer-deps/-/npm-test-peer-deps-0.0.0.tgz',
dependencies: {
underscore: {
version: '1.3.1',
- from: 'underscore@1.3.1',
resolved: common.registry + '/underscore/-/underscore-1.3.1.tgz'
}
}
@@ -133,4 +131,3 @@ test('cleanup', function (t) {
cleanup()
t.done()
})
-
diff --git a/deps/npm/test/tap/peer-deps-without-package-json.js b/deps/npm/test/need-npm5-update/peer-deps-without-package-json.js
index ad863e9f97..ad863e9f97 100644
--- a/deps/npm/test/tap/peer-deps-without-package-json.js
+++ b/deps/npm/test/need-npm5-update/peer-deps-without-package-json.js
diff --git a/deps/npm/test/tap/rm-linked.js b/deps/npm/test/need-npm5-update/rm-linked.js
index 381d7bc67a..381d7bc67a 100644
--- a/deps/npm/test/tap/rm-linked.js
+++ b/deps/npm/test/need-npm5-update/rm-linked.js
diff --git a/deps/npm/test/tap/shrinkwrap-complete-except-dev.js b/deps/npm/test/need-npm5-update/shrinkwrap-complete-except-dev.js
index 156721507f..156721507f 100644
--- a/deps/npm/test/tap/shrinkwrap-complete-except-dev.js
+++ b/deps/npm/test/need-npm5-update/shrinkwrap-complete-except-dev.js
diff --git a/deps/npm/test/tap/shrinkwrap-dev-dep-cycle.js b/deps/npm/test/need-npm5-update/shrinkwrap-dev-dep-cycle.js
index cd5237e161..8e4155d8ac 100644
--- a/deps/npm/test/tap/shrinkwrap-dev-dep-cycle.js
+++ b/deps/npm/test/need-npm5-update/shrinkwrap-dev-dep-cycle.js
@@ -49,7 +49,16 @@ var fixture = new Tacks(
var expectedShrinkwrap = {
name: 'test',
version: '1.0.0',
- dependencies: {}
+ dependencies: {
+ a: {
+ version: '1.0.0',
+ dev: true
+ },
+ b: {
+ version: '1.0.0',
+ dev: true
+ }
+ }
}
function setup () {
diff --git a/deps/npm/test/tap/404-parent.js b/deps/npm/test/tap/404-parent.js
index a8bd951636..4321f7d829 100644
--- a/deps/npm/test/tap/404-parent.js
+++ b/deps/npm/test/tap/404-parent.js
@@ -40,14 +40,14 @@ function setup () {
process.chdir(pkg)
}
-function plugin (server) {
- server.get('/test-npm-404-parent-test')
- .reply(404, {'error': 'version not found'})
-}
-
function performInstall (cb) {
- mr({port: common.port, plugin: plugin}, function (er, s) { // create mock registry.
- npm.load({registry: common.registry}, function () {
+ mr({port: common.port}, function (er, s) { // create mock registry.
+ s.get('/test-npm-404-parent-test')
+ .many().reply(404, {'error': 'version not found'})
+ npm.load({
+ registry: common.registry
+ }, function () {
+ npm.config.set('fetch-retries', 0)
var pwd = process.cwd()
process.chdir(pkg)
npm.commands.install([], function (err) {
diff --git a/deps/npm/test/tap/404-private-registry-scoped.js b/deps/npm/test/tap/404-private-registry-scoped.js
index 0f0cbc4ec7..48889376ca 100644
--- a/deps/npm/test/tap/404-private-registry-scoped.js
+++ b/deps/npm/test/tap/404-private-registry-scoped.js
@@ -42,7 +42,7 @@ test('scoped package names not mangled on error with non-root registry', functio
t.ifError(er, 'correctly handled 404')
t.equal(code, 1, 'exited with error')
t.match(stderr, /E404/, 'should notify the sort of error as a 404')
- t.match(stderr, /@scope\/foo/, 'should have package name in error')
+ t.match(stderr, /@scope(?:%2f|\/)foo/, 'should have package name in error')
server.done()
t.end()
}
diff --git a/deps/npm/test/tap/add-local.js b/deps/npm/test/tap/add-local.js
deleted file mode 100644
index cc615b8997..0000000000
--- a/deps/npm/test/tap/add-local.js
+++ /dev/null
@@ -1,137 +0,0 @@
-var path = require('path')
-var test = require('tap').test
-var mkdirp = require('mkdirp')
-var osenv = require('osenv')
-var rimraf = require('rimraf')
-var requireInject = require('require-inject')
-
-var pkg = path.join(__dirname, '/local-dir')
-var cache = path.join(pkg, '/cache')
-var tmp = path.join(pkg, '/tmp')
-var prefix = path.join(pkg, '/prefix')
-
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-test('addLocal directory race on Windows', function (t) {
- setup()
- var p = {
- name: 'test',
- version: '1.0.0',
- type: 'directory',
- spec: pkg
- }
- var fixture = new Tacks(
- Dir({
- 'package.json': File(p)
- })
- )
- var addLocal = requireInject('../../lib/cache/add-local', {
- '../../lib/npm.js': {
- cache: cache,
- tmp: tmp,
- prefix: prefix
- },
- '../../lib/cache/get-stat': function (cb) {
- cb(null, {})
- },
- chownr: function (x, y, z, cb) {
- cb(new Error('chownr should never have been called'))
- },
- '../../lib/cache/add-local-tarball.js': function (tgz, data, shasum, cb) {
- cb(null)
- },
- '../../lib/utils/lifecycle.js': function (data, cycle, p, cb) {
- cb(null)
- },
- '../../lib/utils/tar.js': {
- pack: function (tgz, p, data, cb) {
- cb(null)
- }
- },
- 'sha': {
- get: function (tgz, cb) {
- cb(null, 'deadbeef')
- }
- }
- })
-
- fixture.create(pkg)
- addLocal(p, null, function (err) {
- t.ifErr(err, 'addLocal completed without error')
- t.done()
- })
-})
-
-test('addLocal temporary cache file race', function (t) {
- // See https://github.com/npm/npm/issues/12669
- setup()
- var p = {
- name: 'test',
- version: '1.0.0',
- type: 'directory',
- spec: pkg
- }
- var fixture = new Tacks(
- Dir({
- 'package.json': File(p)
- })
- )
- var addLocal = requireInject('../../lib/cache/add-local', {
- // basic setup/mock stuff
- '../../lib/npm.js': {
- cache: cache,
- tmp: tmp,
- prefix: prefix
- },
- '../../lib/cache/add-local-tarball.js': function (tgz, data, shasum, cb) {
- cb(null)
- },
- '../../lib/utils/lifecycle.js': function (data, cycle, p, cb) {
- cb(null)
- },
- '../../lib/utils/tar.js': {
- pack: function (tgz, p, data, cb) {
- cb(null)
- }
- },
- 'sha': {
- get: function (tgz, cb) {
- cb(null, 'deadbeef')
- }
- },
-
- // Test-specific mocked values to simulate race.
- '../../lib/cache/get-stat': function (cb) {
- cb(null, {uid: 1, gid: 2})
- },
- chownr: function (x, y, z, cb) {
- // Simulate a race condition between `tar.pack` and `chownr`
- // where the latter will return `ENOENT` when an async process
- // removes a file that its internal `fs.readdir` listed.
- cb({code: 'ENOENT'})
- }
- })
-
- fixture.create(pkg)
- addLocal(p, null, function (err) {
- t.ifErr(err, 'addLocal completed without error')
- t.done()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.done()
-})
-
-function setup () {
- mkdirp.sync(cache)
- mkdirp.sync(tmp)
-}
-
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/add-named-update-protocol-port.js b/deps/npm/test/tap/add-named-update-protocol-port.js
index 78130e2f89..37851e1068 100644
--- a/deps/npm/test/tap/add-named-update-protocol-port.js
+++ b/deps/npm/test/tap/add-named-update-protocol-port.js
@@ -72,6 +72,7 @@ test('tarball paths should update port if updating protocol', function (t) {
{},
function (er, code, stdout, stderr) {
if (er) { throw er }
+ t.equal(stderr, '', 'no error output')
t.equal(code, 0, 'addNamed worked')
server1.done()
t.end()
diff --git a/deps/npm/test/tap/add-remote-git-fake-windows.js b/deps/npm/test/tap/add-remote-git-fake-windows.js
deleted file mode 100644
index 24175c5455..0000000000
--- a/deps/npm/test/tap/add-remote-git-fake-windows.js
+++ /dev/null
@@ -1,132 +0,0 @@
-var fs = require('fs')
-var resolve = require('path').resolve
-
-var osenv = require('osenv')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var test = require('tap').test
-
-var npm = require('../../lib/npm.js')
-var common = require('../common-tap.js')
-
-var pkg = resolve(__dirname, 'add-remote-git')
-var repo = resolve(__dirname, 'add-remote-git-repo')
-
-var daemon
-var daemonPID
-var git
-
-var pjParent = JSON.stringify({
- name: 'parent',
- version: '1.2.3',
- dependencies: {
- child: 'git://localhost:1234/child.git'
- }
-}, null, 2) + '\n'
-
-var pjChild = JSON.stringify({
- name: 'child',
- version: '1.0.3'
-}, null, 2) + '\n'
-
-test('setup', function (t) {
- bootstrap()
- setup(function (er, r) {
- if (er) {
- throw er
- }
-
- if (!er) {
- daemon = r[r.length - 2]
- daemonPID = r[r.length - 1]
- }
-
- t.end()
- })
-})
-
-test('install from repo on \'Windows\'', function (t) {
- // before we confuse everything by switching the platform
- require('../../lib/install.js')
- require('../../lib/unbuild.js')
- process.platform = 'win32'
- process.chdir(pkg)
- npm.commands.install('.', [], function (er) {
- t.ifError(er, 'npm installed via git')
-
- t.end()
- })
-})
-
-test('clean', function (t) {
- daemon.on('close', function () {
- cleanup()
- t.end()
- })
- process.kill(daemonPID)
-})
-
-function bootstrap () {
- rimraf.sync(pkg)
- mkdirp.sync(pkg)
- fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
-}
-
-function setup (cb) {
- rimraf.sync(repo)
- mkdirp.sync(repo)
- fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
- npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
- // some really cheesy monkeypatching
- require('module')._cache[require.resolve('which')] = {
- exports: function (_, cb) { cb() }
- }
- git = require('../../lib/utils/git.js')
-
- function startDaemon (cb) {
- // start git server
- var d = git.spawn(
- [
- 'daemon',
- '--verbose',
- '--listen=localhost',
- '--export-all',
- '--base-path=.',
- '--reuseaddr',
- '--port=1234'
- ],
- {
- cwd: pkg,
- env: process.env,
- stdio: ['pipe', 'pipe', 'pipe']
- }
- )
- d.stderr.on('data', childFinder)
-
- function childFinder (c) {
- var cpid = c.toString().match(/^\[(\d+)\]/)
- if (cpid[1]) {
- this.removeListener('data', childFinder)
- cb(null, [d, cpid[1]])
- }
- }
- }
-
- common.makeGitRepo({
- path: repo,
- commands: [
- git.chainableExec(
- ['clone', '--bare', repo, 'child.git'],
- { cwd: pkg, env: process.env }
- ),
- startDaemon
- ]
- }, cb)
- })
-}
-
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(repo)
- rimraf.sync(pkg)
-}
diff --git a/deps/npm/test/tap/add-remote-git-file.js b/deps/npm/test/tap/add-remote-git-file.js
index eff4a62e2f..546a73ff65 100644
--- a/deps/npm/test/tap/add-remote-git-file.js
+++ b/deps/npm/test/tap/add-remote-git-file.js
@@ -1,3 +1,5 @@
+'use strict'
+
var fs = require('fs')
var resolve = require('path').resolve
var url = require('url')
@@ -32,16 +34,13 @@ test('setup', function (t) {
test('cache from repo', function (t) {
process.chdir(pkg)
- var addRemoteGit = require('../../lib/cache/add-remote-git.js')
- addRemoteGit(cloneURL, function (er, data) {
- t.ifError(er, 'cached via git')
+ return npm.commands.cache.add(cloneURL).then((data) => {
t.equal(
- url.parse(data._resolved).protocol,
+ url.parse(data.manifest._resolved).protocol,
'git+file:',
'npm didn\'t go crazy adding git+git+git+git'
)
-
- t.end()
+ t.equal(data.manifest._spec.type, 'git', 'cached git')
})
})
diff --git a/deps/npm/test/tap/add-remote-git-shrinkwrap.js b/deps/npm/test/tap/add-remote-git-shrinkwrap.js
index b79405c2b8..c7fb2f9b96 100644
--- a/deps/npm/test/tap/add-remote-git-shrinkwrap.js
+++ b/deps/npm/test/tap/add-remote-git-shrinkwrap.js
@@ -45,8 +45,9 @@ test('setup', function (t) {
test('install from repo', function (t) {
process.chdir(pkg)
- npm.commands.install('.', [], function (er) {
- t.ifError(er, 'npm installed via git')
+ common.npm(['install'], {cwd: pkg, stdio: [0, 1, 2]}, function (er, code) {
+ if (er) throw er
+ t.is(code, 0, 'npm installed via git')
t.end()
})
@@ -56,22 +57,14 @@ test('shrinkwrap gets correct _from and _resolved (#7121)', function (t) {
common.npm(
[
'shrinkwrap',
- '--loglevel', 'silent'
+ '--loglevel', 'error'
],
- { cwd: pkg },
- function (er, code, stdout, stderr) {
- t.ifError(er, 'npm shrinkwrapped without errors')
+ { cwd: pkg, stdio: [0, 'pipe', 2] },
+ function (er, code, stdout) {
+ if (er) throw er
t.is(code, 0, '`npm shrinkwrap` exited ok')
- t.equal(stdout.trim(), 'wrote npm-shrinkwrap.json')
- t.equal(stderr.trim(), '', 'no error output on successful shrinkwrap')
var shrinkwrap = require(resolve(pkg, 'npm-shrinkwrap.json'))
- t.equal(
- shrinkwrap.dependencies.child.from,
- 'git://localhost:1234/child.git#master',
- 'npm shrinkwrapped from correctly'
- )
-
git.whichAndExec(
['rev-list', '-n1', 'master'],
{ cwd: repo, env: process.env },
@@ -80,9 +73,7 @@ test('shrinkwrap gets correct _from and _resolved (#7121)', function (t) {
t.notOk(stderr, 'no error output')
var treeish = stdout.trim()
- t.equal(
- shrinkwrap.dependencies.child.resolved,
- 'git://localhost:1234/child.git#' + treeish,
+ t.like(shrinkwrap, {dependencies: {child: {version: 'git://localhost:1234/child.git#' + treeish}}},
'npm shrinkwrapped resolved correctly'
)
@@ -102,6 +93,7 @@ test('clean', function (t) {
})
function bootstrap () {
+ cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
}
diff --git a/deps/npm/test/tap/anon-cli-metrics.js b/deps/npm/test/tap/anon-cli-metrics.js
index cdabd1dc6d..2ece5a1e6c 100644
--- a/deps/npm/test/tap/anon-cli-metrics.js
+++ b/deps/npm/test/tap/anon-cli-metrics.js
@@ -1,6 +1,7 @@
'use strict'
var path = require('path')
var fs = require('graceful-fs')
+var rimraf = require('rimraf')
var test = require('tap').test
var mr = require('npm-registry-mock')
var Tacks = require('tacks')
@@ -74,6 +75,10 @@ function cleanup () {
fixture.remove(basedir)
}
+function reset () {
+ rimraf.sync(testdir + '/' + 'node_modules')
+}
+
test('setup', function (t) {
setup()
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
@@ -91,51 +96,51 @@ test('setup', function (t) {
})
test('record success', function (t) {
- common.npm(['install', '--no-send-metrics', 'success'], conf, function (err, code, stdout, stderr) {
+ common.npm(['install', '--no-save', '--no-send-metrics', 'file:success'], conf, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'always succeeding install succeeded')
t.comment(stdout.trim())
t.comment(stderr.trim())
var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1)
- t.is(data.metrics.failedInstalls, 0)
+ t.is(data.metrics.successfulInstalls, 1, 'successes')
+ t.is(data.metrics.failedInstalls, 0, 'failures')
t.done()
})
})
test('record failure', function (t) {
+ reset()
server.put('/-/npm/anon-metrics/v1/:id', {
successfulInstalls: 1,
failedInstalls: 0
}).reply(500, {ok: false})
- common.npm(['install', '--send-metrics', 'failure'], conf, function (err, code, stdout, stderr) {
+ common.npm(['install', '--no-save', '--send-metrics', 'file:failure'], conf, function (err, code, stdout, stderr) {
if (err) throw err
t.notEqual(code, 0, 'always failing install fails')
t.comment(stdout.trim())
t.comment(stderr.trim())
var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1)
- t.is(data.metrics.failedInstalls, 1)
+ t.is(data.metrics.successfulInstalls, 1, 'successes')
+ t.is(data.metrics.failedInstalls, 1, 'failures')
t.done()
})
})
test('report', function (t) {
- console.log('setup')
-
+ reset()
server.put('/-/npm/anon-metrics/v1/:id', {
successfulInstalls: 1,
failedInstalls: 1
}).reply(200, {ok: true})
- common.npm(['install', '--send-metrics', 'slow'], conf, function (err, code, stdout, stderr) {
+ common.npm(['install', '--no-save', '--send-metrics', 'file:slow'], 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())
// todo check mock registry for post
var data = JSON.parse(fs.readFileSync(metricsFile))
- t.is(data.metrics.successfulInstalls, 1)
- t.is(data.metrics.failedInstalls, 0)
+ t.is(data.metrics.successfulInstalls, 1, 'successes')
+ t.is(data.metrics.failedInstalls, 0, 'failures')
t.done()
})
})
diff --git a/deps/npm/test/tap/bearer-token-check.js b/deps/npm/test/tap/bearer-token-check.js
index f400ec1726..42c8f313e2 100644
--- a/deps/npm/test/tap/bearer-token-check.js
+++ b/deps/npm/test/tap/bearer-token-check.js
@@ -64,12 +64,13 @@ test('authed npm install with tarball not on registry', function (t) {
}
if (results) {
- var installedversion = {
- 'version': '1.3.1',
- 'from': '>=1.3.1 <2',
- 'resolved': tarballURL
- }
- t.isDeeply(results.dependencies['@scoped/underscore'], installedversion, '@scoped/underscore installed')
+ var installedversion = [
+ {
+ 'name': '@scoped/underscore',
+ 'version': '1.3.1'
+ }
+ ]
+ t.match(results.added, installedversion, '@scoped/underscore installed')
}
t.end()
@@ -97,7 +98,6 @@ var shrinkwrap = {
dependencies: {
'@scoped/underscore': {
resolved: tarballURL,
- from: '>=1.3.1 <2',
version: '1.3.1'
}
}
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 7268b50400..ce65f15b28 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
@@ -1,4 +1,7 @@
'use strict'
+
+const BB = require('bluebird')
+
var fs = require('graceful-fs')
var path = require('path')
@@ -31,17 +34,16 @@ test('bitbucket-https-url-with-creds-package', function (t) {
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error())
+ throw new Error('git.revs mock fails on purpose')
})
}
}
@@ -55,8 +57,8 @@ test('bitbucket-https-url-with-creds-package', function (t) {
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
- npm.commands.install([], function (er) {
- t.ok(er, 'mocked install failed as expected')
+ npm.commands.install([], function (err) {
+ t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
t.end()
})
})
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 846e3ae741..ae87d85848 100644
--- a/deps/npm/test/tap/bitbucket-https-url-with-creds.js
+++ b/deps/npm/test/tap/bitbucket-https-url-with-creds.js
@@ -1,4 +1,7 @@
'use strict'
+
+const BB = require('bluebird')
+
var fs = require('graceful-fs')
var path = require('path')
@@ -28,17 +31,16 @@ test('bitbucket-https-url-with-creds', function (t) {
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error('execFile mock fails on purpose'))
+ throw new Error('git.revs mock fails on purpose')
})
}
}
@@ -52,8 +54,8 @@ test('bitbucket-https-url-with-creds', function (t) {
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
- npm.commands.install(['git+https://user:pass@bitbucket.org/foo/private.git'], function (er) {
- t.ok(er, 'mocked install failed as expected')
+ npm.commands.install(['git+https://user:pass@bitbucket.org/foo/private.git'], function (err) {
+ t.match(err, /mock fails on purpose/, 'mocked install failed as expected')
t.end()
})
})
diff --git a/deps/npm/test/tap/bitbucket-shortcut-package.js b/deps/npm/test/tap/bitbucket-shortcut-package.js
index 37fe57950c..8c418d37dc 100644
--- a/deps/npm/test/tap/bitbucket-shortcut-package.js
+++ b/deps/npm/test/tap/bitbucket-shortcut-package.js
@@ -1,4 +1,7 @@
'use strict'
+
+const BB = require('bluebird')
+
var fs = require('graceful-fs')
var path = require('path')
@@ -28,21 +31,20 @@ test('setup', function (t) {
test('bitbucket-shortcut', function (t) {
var cloneUrls = [
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs first'],
- ['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH second']
+ ['ssh://git@bitbucket.org/foo/private.git', 'Bitbucket shortcuts try SSH second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error())
+ throw new Error('git.revs mock fails on purpose')
})
}
}
@@ -56,8 +58,8 @@ test('bitbucket-shortcut', function (t) {
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
- npm.commands.install([], function (er) {
- t.ok(er, 'mocked install failed as expected')
+ npm.commands.install([], function (err) {
+ t.match(err.message, /fails on purpose/, 'mocked install failed as expected')
t.end()
})
})
diff --git a/deps/npm/test/tap/bitbucket-shortcut.js b/deps/npm/test/tap/bitbucket-shortcut.js
index a708d84972..f8167fdd2d 100644
--- a/deps/npm/test/tap/bitbucket-shortcut.js
+++ b/deps/npm/test/tap/bitbucket-shortcut.js
@@ -1,4 +1,7 @@
'use strict'
+
+const BB = require('bluebird')
+
var fs = require('graceful-fs')
var path = require('path')
@@ -25,21 +28,20 @@ test('setup', function (t) {
test('bitbucket-shortcut', function (t) {
var cloneUrls = [
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs first'],
- ['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH second']
+ ['ssh://git@bitbucket.org/foo/private.git', 'Bitbucket shortcuts try SSH second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
var cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error('execFile mock fails on purpose'))
+ throw new Error('git.revs mock fails on purpose')
})
}
}
@@ -53,8 +55,8 @@ test('bitbucket-shortcut', function (t) {
}
npm.load(opts, function (er) {
t.ifError(er, 'npm loaded without error')
- npm.commands.install(['bitbucket:foo/private'], function (er) {
- t.ok(er, 'mocked install failed as expected')
+ npm.commands.install(['bitbucket:foo/private'], function (err) {
+ t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
t.end()
})
})
diff --git a/deps/npm/test/tap/bundled-dependencies-no-pkgjson.js b/deps/npm/test/tap/bundled-dependencies-no-pkgjson.js
index 44eb47a03a..a7056408a9 100644
--- a/deps/npm/test/tap/bundled-dependencies-no-pkgjson.js
+++ b/deps/npm/test/tap/bundled-dependencies-no-pkgjson.js
@@ -19,23 +19,31 @@ var pkgJson = JSON.stringify({
'a-bundled-dep'
]
}, null, 2) + '\n'
+var packed
test('setup', function (t) {
+ rimraf.sync(dir)
mkdirp.sync(path.join(dir, 'node_modules'))
mkdirp.sync(dep)
fs.writeFileSync(path.resolve(pkg, 'package.json'), pkgJson)
fs.writeFileSync(path.resolve(dep, 'index.js'), '')
- t.end()
+ common.npm(['pack', pkg], {cwd: dir}, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'packed ok')
+ packed = stdout.trim()
+ t.comment(stderr)
+ t.end()
+ })
})
test('proper error on bundled dep with no package.json', function (t) {
- t.plan(3)
- var npmArgs = ['install', './' + path.basename(pkg)]
+ t.plan(2)
+ var npmArgs = ['install', packed]
common.npm(npmArgs, { cwd: dir }, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm ran without issue')
- t.notEqual(code, 0)
+ if (err) throw err
+ t.notEqual(code, 0, 'npm ended in error')
t.like(stderr, /ENOENT/, 'ENOENT should be in stderr')
t.end()
})
diff --git a/deps/npm/test/tap/bundled-dependencies-nonarray.js b/deps/npm/test/tap/bundled-dependencies-nonarray.js
index 2a08272008..8f8eeb358f 100644
--- a/deps/npm/test/tap/bundled-dependencies-nonarray.js
+++ b/deps/npm/test/tap/bundled-dependencies-nonarray.js
@@ -1,3 +1,5 @@
+'use strict'
+var Bluebird = require('bluebird')
var fs = require('graceful-fs')
var path = require('path')
@@ -7,7 +9,7 @@ var test = require('tap').test
var common = require('../common-tap.js')
-var dir = path.resolve(__dirname, 'bundleddependencies')
+var dir = path.resolve(__dirname, path.basename(__filename, '.js'))
var pkg = path.resolve(dir, 'pkg-with-bundled')
var dep = path.resolve(dir, 'a-bundled-dep')
@@ -15,10 +17,10 @@ var pj = JSON.stringify({
name: 'pkg-with-bundled',
version: '1.0.0',
dependencies: {
- 'a-bundled-dep': 'file:../a-bundled-dep'
+ 'a-bundled-dep': 'file:../a-bundled-dep-2.0.0.tgz'
},
bundledDependencies: {
- 'a-bundled-dep': 'file:../a-bundled-dep'
+ 'a-bundled-dep': 'file:../a-bundled-dep-2.0.0.tgz'
}
}, null, 2) + '\n'
@@ -33,19 +35,17 @@ test('setup', function (t) {
})
test('errors on non-array bundleddependencies', function (t) {
- t.plan(6)
- common.npm(['install'], { cwd: pkg }, function (err, code, stdout, stderr) {
- t.ifError(err, 'npm install ran without issue')
- t.is(code, 0, 'exited with a non-error code')
- t.is(stderr, '', 'no error output')
-
- common.npm(['install', './pkg-with-bundled'], { cwd: dir },
- function (err, code, stdout, stderr) {
- t.ifError(err, 'npm install ran without issue')
- t.notEqual(code, 0, 'exited with a error code')
- t.like(stderr, /be an array/, 'nice error output')
- }
- )
+ return Bluebird.try(() => {
+ return common.npm(['pack', 'a-bundled-dep/'], {cwd: dir, stdio: [0, 1, 2]})
+ }).spread((code) => {
+ t.is(code, 0, 'built a-bundled-dep')
+ return common.npm(['install'], {cwd: pkg, stdio: [0, 1, 2]})
+ }).spread((code) => {
+ t.is(code, 0, 'prepared pkg-with-bundled')
+ return common.npm(['pack', 'pkg-with-bundled/'], {cwd: dir, stdio: [0, 1, 'pipe']})
+ }).spread((code, _, stderr) => {
+ t.notEqual(code, 0, 'exited with a error code')
+ t.like(stderr, /be an array/, 'nice error output')
})
})
diff --git a/deps/npm/test/tap/cache-add-localdir-fallback.js b/deps/npm/test/tap/cache-add-localdir-fallback.js
deleted file mode 100644
index 2845d11ec0..0000000000
--- a/deps/npm/test/tap/cache-add-localdir-fallback.js
+++ /dev/null
@@ -1,84 +0,0 @@
-var path = require('path')
-var test = require('tap').test
-var npm = require('../../lib/npm.js')
-var requireInject = require('require-inject')
-
-var realizePackageSpecifier = requireInject('realize-package-specifier', {
- 'fs': {
- stat: function (file, cb) {
- process.nextTick(function () {
- switch (file) {
- case path.resolve('named'):
- cb(new Error('ENOENT'))
- break
- case path.resolve('file.tgz'):
- cb(null, { isDirectory: function () { return false } })
- break
- case path.resolve('dir-no-package'):
- cb(null, { isDirectory: function () { return true } })
- break
- case path.resolve('dir-no-package/package.json'):
- cb(new Error('ENOENT'))
- break
- case path.resolve('dir-with-package'):
- cb(null, { isDirectory: function () { return true } })
- break
- case path.resolve('dir-with-package/package.json'):
- cb(null, {})
- break
- case path.resolve(__dirname, 'dir-with-package'):
- cb(null, { isDirectory: function () { return true } })
- break
- case path.join(__dirname, 'dir-with-package', 'package.json'):
- cb(null, {})
- break
- case path.resolve(__dirname, 'file.tgz'):
- cb(null, { isDirectory: function () { return false } })
- break
- default:
- throw new Error('Unknown test file passed to stat: ' + file)
- }
- })
- }
- }
-})
-
-npm.load({ loglevel: 'silent' }, function () {
- var cache = requireInject('../../lib/cache.js', {
- 'realize-package-specifier': realizePackageSpecifier,
- '../../lib/cache/add-named.js': function addNamed (name, version, data, cb) {
- cb(null, 'addNamed')
- },
- '../../lib/cache/add-local.js': function addLocal (name, data, cb) {
- cb(null, 'addLocal')
- }
- })
-
- test('npm install localdir fallback', function (t) {
- t.plan(12)
- cache.add('named', null, null, false, function (er, which) {
- t.ifError(er, 'named was cached')
- t.is(which, 'addNamed', 'registry package name')
- })
- cache.add('file.tgz', null, null, false, function (er, which) {
- t.ifError(er, 'file.tgz was cached')
- t.is(which, 'addLocal', 'local file')
- })
- cache.add('dir-no-package', null, null, false, function (er, which) {
- t.ifError(er, 'local directory was cached')
- t.is(which, 'addNamed', 'local directory w/o package.json')
- })
- cache.add('dir-with-package', null, null, false, function (er, which) {
- t.ifError(er, 'local directory with package was cached')
- t.is(which, 'addLocal', 'local directory with package.json')
- })
- cache.add('file:./dir-with-package', null, __dirname, false, function (er, which) {
- t.ifError(er, 'local directory (as URI) with package was cached')
- t.is(which, 'addLocal', 'file: URI to local directory with package.json')
- })
- cache.add('file:./file.tgz', null, __dirname, false, function (er, which) {
- t.ifError(er, 'local file (as URI) with package was cached')
- t.is(which, 'addLocal', 'file: URI to local file with package.json')
- })
- })
-})
diff --git a/deps/npm/test/tap/cache-ls-filenames.js b/deps/npm/test/tap/cache-ls-filenames.js
deleted file mode 100644
index c67bca25f3..0000000000
--- a/deps/npm/test/tap/cache-ls-filenames.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var t = require('tap')
-var path = require('path')
-var fs = require('fs')
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
-var spawn = require('child_process').spawn
-var npm = require.resolve('../../bin/npm-cli.js')
-var dir = path.resolve(__dirname, 'cache-ls-filenames')
-var node = process.execPath
-
-t.test('setup', function (t) {
- rimraf.sync(dir)
- mkdirp.sync(dir + '/a/b/c/d')
- for (var i = 0; i < 5; i++) {
- fs.writeFileSync(dir + '/file-' + i, 'x\n')
- fs.writeFileSync(dir + '/a/b/file-' + i, 'x\n')
- }
- t.end()
-})
-
-function test (t, args) {
- var child = spawn(node, [npm, 'cache', 'ls', '--cache=' + dir].concat(args))
- var out = ''
- child.stdout.on('data', function (c) {
- out += c
- })
- child.on('close', function (code, signal) {
- t.equal(code, 0)
- t.equal(signal, null)
- out.trim().split(/[\n\r]+/).map(function (filename) {
- return filename.replace(/^~/, process.env.HOME)
- }).forEach(function (file) {
- // verify that all exist
- t.ok(fs.existsSync(file), 'exists: ' + file)
- })
- t.end()
- })
-}
-
-t.test('without path arg', function (t) {
- test(t, [])
-})
-
-t.test('with path arg', function (t) {
- test(t, ['a'])
-})
-
-t.test('cleanup', function (t) {
- rimraf.sync(dir)
- t.end()
-})
diff --git a/deps/npm/test/tap/cache-shasum-fork.js b/deps/npm/test/tap/cache-shasum-fork.js
index 01c2f68fb7..1e92d43756 100644
--- a/deps/npm/test/tap/cache-shasum-fork.js
+++ b/deps/npm/test/tap/cache-shasum-fork.js
@@ -18,9 +18,6 @@ var pkg = path.resolve(__dirname, 'cache-shasum-fork')
var cache = path.join(pkg, 'cache')
var server
-var installed_output = path.join(__dirname, 'cache-shasum-fork') +
- '\n`-- underscore@1.5.1 \n\n'
-
test('setup', function (t) {
setup()
t.comment('test for https://github.com/npm/npm/issues/3265')
@@ -35,6 +32,7 @@ test('npm cache - install from fork', function (t) {
common.npm(
[
'--loglevel', 'silent',
+ '--json',
'--registry', common.registry,
'install', forkPath
],
@@ -47,7 +45,9 @@ test('npm cache - install from fork', function (t) {
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.equal(code, 0, 'install finished successfully')
- t.equal(stdout, installed_output)
+ var deps = {}
+ JSON.parse(stdout).added.forEach(function (dep) { deps[dep.name] = dep })
+ t.equal(deps.underscore && deps.underscore.version, '1.5.1')
var index = fs.readFileSync(
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
'utf8'
@@ -64,6 +64,7 @@ test('npm cache - install from origin', function (t) {
common.npm(
[
'--loglevel', 'silent',
+ '--json',
'--registry', common.registry,
'install', 'underscore'
],
@@ -75,7 +76,9 @@ test('npm cache - install from origin', function (t) {
t.ifErr(err, 'install finished without error')
t.equal(code, 0, 'install finished successfully')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
- t.equal(stdout, installed_output)
+ var deps = {}
+ JSON.parse(stdout).updated.forEach(function (dep) { deps[dep.name] = dep })
+ t.equal(deps.underscore && deps.underscore.version, '1.5.1')
var index = fs.readFileSync(
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
'utf8'
diff --git a/deps/npm/test/tap/cache-shasum.js b/deps/npm/test/tap/cache-shasum.js
deleted file mode 100644
index 40495c0995..0000000000
--- a/deps/npm/test/tap/cache-shasum.js
+++ /dev/null
@@ -1,50 +0,0 @@
-var test = require('tap').test
-var path = require('path')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var common = require('../common-tap.js')
-var cache = path.resolve(__dirname, 'cache-shasum')
-var sha = require('sha')
-var server
-
-test('mock reg', function (t) {
- rimraf.sync(cache)
- mkdirp.sync(cache)
- mr({ port: common.port }, function (er, s) {
- server = s
- t.pass('ok')
- t.end()
- })
-})
-
-test('npm cache add request', function (t) {
- common.npm([
- 'cache', 'add', 'request@2.27.0',
- '--cache=' + cache,
- '--registry=' + common.registry,
- '--loglevel=error'
- ], {}, function (err, code, stdout) {
- if (err) throw err
- t.is(code, 0, 'cmd ran without error')
- t.is(stdout, '', 'should not get data on stdout')
- t.end()
- })
-})
-
-test('compare', function (t) {
- var d = path.resolve(__dirname, 'cache-shasum/request')
- var p = path.resolve(d, '2.27.0/package.tgz')
- var r = require('./cache-shasum/localhost_1337/request/.cache.json')
- var rshasum = r.versions['2.27.0'].dist.shasum
- sha.get(p, function (er, pshasum) {
- if (er) throw er
- t.equal(pshasum, rshasum)
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- rimraf(cache, t.end)
-})
diff --git a/deps/npm/test/tap/config-meta.js b/deps/npm/test/tap/config-meta.js
index 168ab2a2e7..d7897a16ce 100644
--- a/deps/npm/test/tap/config-meta.js
+++ b/deps/npm/test/tap/config-meta.js
@@ -18,7 +18,9 @@ var DOC = {}
var exceptions = [
path.resolve(lib, 'adduser.js'),
path.resolve(lib, 'config.js'),
+ path.resolve(lib, 'config', 'pacote.js'),
path.resolve(lib, 'publish.js'),
+ path.resolve(lib, 'install', 'inflate-shrinkwrap.js'),
path.resolve(lib, 'utils', 'lifecycle.js'),
path.resolve(lib, 'utils', 'map-to-registry.js'),
path.resolve(nm, 'npm-registry-client', 'lib', 'publish.js'),
diff --git a/deps/npm/test/tap/dedupe-scoped.js b/deps/npm/test/tap/dedupe-scoped.js
index bcd520420b..9d5ff9ac4c 100644
--- a/deps/npm/test/tap/dedupe-scoped.js
+++ b/deps/npm/test/tap/dedupe-scoped.js
@@ -12,10 +12,10 @@ var modules = join(pkg, 'node_modules')
var EXEC_OPTS = { cwd: pkg }
var body = [
- '@scope/shared@2.1.6 node_modules/first/node_modules/@scope/shared -> node_modules/@scope/shared',
- 'firstUnique@0.6.0 node_modules/first/node_modules/firstUnique -> node_modules/firstUnique',
- 'secondUnique@1.2.0 node_modules/second/node_modules/secondUnique -> node_modules/secondUnique',
- '- @scope/shared@2.1.6 node_modules/second/node_modules/@scope/shared'
+ 'move\t@scope/shared\t2.1.6\tnode_modules/@scope/shared\t\tnode_modules/first/node_modules/@scope/shared',
+ 'move\tfirstUnique\t0.6.0\tnode_modules/firstUnique\t\tnode_modules/first/node_modules/firstUnique',
+ 'remove\t@scope/shared\t2.1.6\tnode_modules/second/node_modules/@scope/shared',
+ 'move\tsecondUnique\t1.2.0\tnode_modules/secondUnique\t\tnode_modules/second/node_modules/secondUnique'
]
var deduper = {
@@ -33,7 +33,9 @@ var first = {
'dependencies': {
'firstUnique': '0.6.0',
'@scope/shared': '2.1.6'
- }
+ },
+ '_resolved': 'foo',
+ '_integrity': 'sha1-deadbeef'
}
var second = {
@@ -42,22 +44,30 @@ var second = {
'dependencies': {
'secondUnique': '1.2.0',
'@scope/shared': '2.1.6'
- }
+ },
+ '_resolved': 'foo',
+ '_integrity': 'sha1-deadbeef'
}
var shared = {
'name': '@scope/shared',
- 'version': '2.1.6'
+ 'version': '2.1.6',
+ '_resolved': 'foo',
+ '_integrity': 'sha1-deadbeef'
}
var firstUnique = {
'name': 'firstUnique',
- 'version': '0.6.0'
+ 'version': '0.6.0',
+ '_resolved': 'foo',
+ '_integrity': 'sha1-deadbeef'
}
var secondUnique = {
'name': 'secondUnique',
- 'version': '1.2.0'
+ 'version': '1.2.0',
+ '_resolved': 'foo',
+ '_integrity': 'sha1-deadbeef'
}
test('setup', function (t) {
diff --git a/deps/npm/test/tap/dedupe.js b/deps/npm/test/tap/dedupe.js
index bdda3474ac..b6c601cbad 100644
--- a/deps/npm/test/tap/dedupe.js
+++ b/deps/npm/test/tap/dedupe.js
@@ -60,6 +60,7 @@ test('setup', function (t) {
test('dedupe finds the common module and moves it up one level', function (t) {
common.npm([
'--registry', common.registry,
+ '--no-save',
'install', '.'
],
EXEC_OPTS,
diff --git a/deps/npm/test/tap/doctor.js b/deps/npm/test/tap/doctor.js
index 5cdffb2bd8..fa1a5fad1c 100644
--- a/deps/npm/test/tap/doctor.js
+++ b/deps/npm/test/tap/doctor.js
@@ -1,45 +1,76 @@
'use strict'
-var http = require('http')
-var which = require('which')
-var mr = require('npm-registry-mock')
-var test = require('tap').test
-var common = require('../common-tap.js')
-var npm = require('../../lib/npm.js')
-var server
-var node_url
-var pingResponse = {
+
+const common = require('../common-tap.js')
+const http = require('http')
+const mr = require('npm-registry-mock')
+const npm = require('../../lib/npm.js')
+const path = require('path')
+const rimraf = require('rimraf')
+const Tacks = require('tacks')
+const test = require('tap').test
+const which = require('which')
+
+const Dir = Tacks.Dir
+const File = Tacks.File
+
+const ROOT = path.join(__dirname, path.basename(__filename, '.js'))
+const CACHE = path.join(ROOT, 'cache')
+const TMP = path.join(ROOT, 'tmp')
+const PREFIX = path.join(ROOT, 'global-prefix')
+const PKG = path.join(ROOT, 'pkg')
+
+let server
+let node_url
+const pingResponse = {
host: 'registry.npmjs.org',
ok: true,
username: null,
peer: 'example.com'
}
-var npmResponse = {
+const npmResponse = {
+ name: 'npm',
'dist-tags': {latest: '0.0.0'},
'versions': {
'0.0.0': {
+ name: 'npm',
version: '0.0.0',
+ _shrinkwrap: null,
+ _hasShrinkwrap: false,
dist: {
- shasum: '',
- tarball: ''
+ shasum: 'deadbeef',
+ tarball: 'https://reg.eh/npm-0.0.0.tgz'
}
}
}
}
-test('setup', function (t) {
- var port = common.port + 1
+test('setup', (t) => {
+ const port = common.port + 1
http.createServer(function (q, s) {
s.end(JSON.stringify([{lts: true, version: '0.0.0'}]))
this.close()
- }).listen(port, function () {
+ }).listen(port, () => {
node_url = 'http://localhost:' + port
- mr({port: common.port}, function (e, s) {
- t.ifError(e, 'registry mocked successfully')
+ mr({port: common.port}, (err, s) => {
+ t.ifError(err, 'registry mocked successfully')
server = s
server.get('/-/ping?write=true').reply(200, JSON.stringify(pingResponse))
server.get('/npm').reply(200, JSON.stringify(npmResponse))
- npm.load({registry: common.registry, loglevel: 'silent'}, function (e) {
- t.ifError(e, 'npm loaded successfully')
+ const fixture = new Tacks(Dir({
+ [path.basename(PKG)]: Dir({
+ 'package.json': File({name: 'foo', version: '1.0.0'})
+ }),
+ [path.basename(PREFIX)]: Dir({})
+ }))
+ fixture.create(ROOT)
+ npm.load({
+ registry: common.registry,
+ loglevel: 'silent',
+ cache: CACHE,
+ tmp: TMP,
+ prefix: PREFIX
+ }, (err) => {
+ t.ifError(err, 'npm loaded successfully')
t.pass('all set up')
t.done()
})
@@ -51,14 +82,14 @@ test('npm doctor', function (t) {
npm.commands.doctor({'node-url': node_url}, true, function (e, list) {
t.ifError(e, 'npm loaded successfully')
t.same(list.length, 9, 'list should have 9 prop')
- t.same(list[0][1], 'ok', 'npm ping')
+ t.same(list[0][1], 'OK', 'npm ping')
t.same(list[1][1], 'v' + npm.version, 'npm -v')
t.same(list[2][1], process.version, 'node -v')
t.same(list[3][1], common.registry + '/', 'npm config get registry')
t.same(list[5][1], 'ok', 'Perms check on cached files')
t.same(list[6][1], 'ok', 'Perms check on global node_modules')
t.same(list[7][1], 'ok', 'Perms check on local node_modules')
- t.same(list[8][1], 'ok', 'Checksum cached files')
+ t.match(list[8][1], /^verified \d+ tarballs?$/, 'Cache verified')
which('git', function (e, resolvedPath) {
t.ifError(e, 'git command is installed')
t.same(list[4][1], resolvedPath, 'which git')
@@ -67,3 +98,8 @@ test('npm doctor', function (t) {
})
})
})
+
+test('cleanup', (t) => {
+ rimraf.sync(ROOT)
+ t.done()
+})
diff --git a/deps/npm/test/tap/fetch-package-metadata.js b/deps/npm/test/tap/fetch-package-metadata.js
index c7a7fcbe1a..2fc501369e 100644
--- a/deps/npm/test/tap/fetch-package-metadata.js
+++ b/deps/npm/test/tap/fetch-package-metadata.js
@@ -3,6 +3,7 @@ var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
+var npa = require('npm-package-arg')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
@@ -36,18 +37,11 @@ test('setup', function (t) {
})
test('fetch-package-metadata provides resolved metadata', function (t) {
- t.plan(5)
+ t.plan(4)
var fetchPackageMetadata = require('../../lib/fetch-package-metadata')
- var testPackage = {
- raw: 'test-package@>=0.0.0',
- scope: null,
- name: 'test-package',
- rawSpec: '>=0.0.0',
- spec: '>=0.0.0',
- type: 'range'
- }
+ var testPackage = npa('test-package@>=0.0.0')
mr({ port: common.port }, thenFetchMetadata)
@@ -63,8 +57,7 @@ test('fetch-package-metadata provides resolved metadata', function (t) {
t.ifError(err, 'fetched metadata')
t.equals(pkg._resolved, 'http://localhost:1337/test-package/-/test-package-0.0.0.tgz', '_resolved')
- t.equals(pkg._shasum, 'b0d32b6c45c259c578ba2003762b205131bdfbd1', '_shasum')
- t.equals(pkg._from, 'test-package@>=0.0.0', '_from')
+ t.equals(pkg._integrity, 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E=', '_integrity')
server.close()
t.end()
}
diff --git a/deps/npm/test/tap/files-and-ignores.js b/deps/npm/test/tap/files-and-ignores.js
index 88d9d12922..d86b17acfa 100644
--- a/deps/npm/test/tap/files-and-ignores.js
+++ b/deps/npm/test/tap/files-and-ignores.js
@@ -405,7 +405,8 @@ test('certain files ignored unconditionally', function (t) {
'.foo.swp',
'.DS_Store',
'._ohno',
- 'foo.orig'
+ 'foo.orig',
+ 'package-lock.json'
]
}),
'.git': Dir({foo: File('')}),
@@ -423,7 +424,8 @@ test('certain files ignored unconditionally', function (t) {
'.DS_Store': Dir({foo: File('')}),
'._ohno': File(''),
'._ohnoes': Dir({noes: File('')}),
- 'foo.orig': File('')
+ 'foo.orig': File(''),
+ 'package-lock.json': File('')
})
)
withFixture(t, fixture, function (done) {
@@ -443,6 +445,7 @@ test('certain files ignored unconditionally', function (t) {
t.notOk(fileExists('._ohno'), '._ohno not included')
t.notOk(fileExists('._ohnoes'), '._ohnoes not included')
t.notOk(fileExists('foo.orig'), 'foo.orig not included')
+ t.notOk(fileExists('package-lock.json'), 'package-lock.json not included')
done()
})
})
diff --git a/deps/npm/test/tap/full-warning-messages.js b/deps/npm/test/tap/full-warning-messages.js
index 6745ee3db2..c986695d67 100644
--- a/deps/npm/test/tap/full-warning-messages.js
+++ b/deps/npm/test/tap/full-warning-messages.js
@@ -87,15 +87,19 @@ function notExists (t, filepath, msg) {
}
test('tree-style', function (t) {
- common.npm(['install', '--loglevel=warn'], {cwd: base}, function (err, code, stdout, stderr) {
+ common.npm(['install', '--json', '--loglevel=warn'], {cwd: base}, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'result code')
- t.match(stdout, /modA@1.0.0/, 'modA got installed')
- t.notMatch(stdout, /modB/, 'modB not installed')
+ var result = JSON.parse(stdout)
+ t.is(result.added.length, 1, 'only added one module')
+ t.is(result.added[0].name, 'modA', 'modA got installed')
+ t.is(result.warnings.length, 1, 'one warning')
var stderrlines = stderr.trim().split(/\n/)
t.is(stderrlines.length, 2, 'two lines of warnings')
- t.match(stderr, /SKIPPING OPTIONAL DEPENDENCY/, 'expected optional failure warning')
- t.match(stderr, /Unsupported platform/, 'reason for optional failure')
+ t.match(stderr, /SKIPPING OPTIONAL DEPENDENCY/, 'expected optional failure warning in stderr')
+ t.match(stderr, /Unsupported platform/, 'reason for optional failure in stderr')
+ t.match(result.warnings[0], /SKIPPING OPTIONAL DEPENDENCY/, 'expected optional failure warning in JSON')
+ t.match(result.warnings[0], /Unsupported platform/, 'reason for optional failure in JSON')
exists(t, modJoin(base, 'modA'), 'module A')
notExists(t, modJoin(base, 'modB'), 'module B')
t.done()
diff --git a/deps/npm/test/tap/gently-rm-overeager.js b/deps/npm/test/tap/gently-rm-overeager.js
index 08fa72bc71..7299b2c3f4 100644
--- a/deps/npm/test/tap/gently-rm-overeager.js
+++ b/deps/npm/test/tap/gently-rm-overeager.js
@@ -6,8 +6,9 @@ var rimraf = require('rimraf')
var common = require('../common-tap.js')
-var pkg = path.join(__dirname, 'gently-rm-overeager')
-var dep = path.join(__dirname, 'test-whoops')
+var testdir = path.join(__dirname, path.basename(__filename, '.js'))
+var pkg = path.join(testdir, 'gently-rm-overeager')
+var dep = path.join(testdir, 'test-whoops')
var EXEC_OPTS = { cwd: pkg }
@@ -23,11 +24,13 @@ test('setup', function (t) {
cleanup()
setup()
- t.end()
+ return common.npm(['pack', 'file:test-whoops'], {cwd: testdir, stdio: 'inherit'}).spread((code) => {
+ t.is(code, 0, 'pack')
+ })
})
test('cache add', function (t) {
- common.npm(['install', '../test-whoops'], EXEC_OPTS, function (er, c) {
+ common.npm(['install', '--no-save', '../test-whoops-1.0.0.tgz'], EXEC_OPTS, function (er, c) {
t.ifError(er, "test-whoops install didn't explode")
t.ok(c, 'test-whoops install also failed')
fs.readdir(pkg, function (er, files) {
@@ -45,8 +48,7 @@ test('cleanup', function (t) {
})
function cleanup () {
- rimraf.sync(pkg)
- rimraf.sync(dep)
+ rimraf.sync(testdir)
}
function setup () {
diff --git a/deps/npm/test/tap/gently-rm-symlinked-global-dir.js b/deps/npm/test/tap/gently-rm-symlinked-global-dir.js
index b159a4ec2f..8ac290091c 100644
--- a/deps/npm/test/tap/gently-rm-symlinked-global-dir.js
+++ b/deps/npm/test/tap/gently-rm-symlinked-global-dir.js
@@ -37,7 +37,7 @@ test('install and link', function (t) {
'--global',
'--prefix', lnk,
'--loglevel', 'silent',
- '--unicode', 'false',
+ '--json',
'install', '../test-linked'
],
EXEC_OPTS,
@@ -54,7 +54,7 @@ test('install and link', function (t) {
'--global',
'--prefix', lnk,
'--loglevel', 'silent',
- '--unicode', 'false',
+ '--json',
'install', '../test-linked'
],
EXEC_OPTS,
@@ -83,27 +83,21 @@ test('cleanup', function (t) {
t.end()
})
-function removeBlank (line) {
- return line !== ''
-}
-
function resolvePath () {
return resolve.apply(null, Array.prototype.slice.call(arguments)
.filter(function (arg) { return arg }))
}
function verify (t, stdout) {
- var binPath = resolvePath(lnk, !isWindows && 'bin', 'linked')
+ var result = JSON.parse(stdout)
var pkgPath = resolvePath(lnk, !isWindows && 'lib', 'node_modules', '@test', 'linked')
- var trgPath = resolvePath(pkgPath, 'index.js')
- t.deepEqual(
- stdout.split('\n').filter(removeBlank),
- [ binPath + ' -> ' + trgPath,
- resolvePath(lnk, !isWindows && 'lib'),
- '`-- @test/linked@1.0.0 '
- ],
- 'got expected install output'
- )
+ if (result.added.length) {
+ t.is(result.added.length, 1, 'added the module')
+ t.is(result.added[0].path, pkgPath, 'in the right location')
+ } else {
+ t.is(result.updated.length, 1, 'updated the module')
+ t.is(result.updated[0].path, pkgPath, 'in the right location')
+ }
}
function cleanup () {
diff --git a/deps/npm/test/tap/get.js b/deps/npm/test/tap/get.js
index 62bb05fda7..c939ed071e 100644
--- a/deps/npm/test/tap/get.js
+++ b/deps/npm/test/tap/get.js
@@ -1,12 +1,9 @@
var common = require('../common-tap.js')
var test = require('tap').test
-var cacheFile = require('npm-cache-filename')
var npm = require('../../')
-var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var path = require('path')
var mr = require('npm-registry-mock')
-var fs = require('graceful-fs')
function nop () {}
@@ -23,7 +20,6 @@ var PARAMS = {
auth: AUTH
}
var PKG_DIR = path.resolve(__dirname, 'get-basic')
-var CACHE_DIR = path.resolve(PKG_DIR, 'cache')
var BIGCO_SAMPLE = {
name: '@bigco/sample',
version: '1.2.3'
@@ -38,18 +34,10 @@ var mocks = {
}
}
-var mapper = cacheFile(CACHE_DIR)
-
-function getCachePath (uri) {
- return path.join(mapper(uri), '.cache.json')
-}
-
test('setup', function (t) {
- mkdirp.sync(CACHE_DIR)
-
mr({port: common.port, mocks: mocks}, function (er, s) {
t.ifError(er)
- npm.load({cache: CACHE_DIR, registry: common.registry}, function (er) {
+ npm.load({registry: common.registry}, function (er) {
t.ifError(er)
server = s
t.end()
@@ -86,33 +74,24 @@ test('get call contract', function (t) {
})
test('basic request', function (t) {
- t.plan(9)
+ t.plan(6)
var versioned = common.registry + '/underscore/1.3.3'
npm.registry.get(versioned, PARAMS, function (er, data) {
t.ifError(er, 'loaded specified version underscore data')
t.equal(data.version, '1.3.3')
- fs.stat(getCachePath(versioned), function (er) {
- t.ifError(er, 'underscore 1.3.3 cache data written')
- })
})
var rollup = common.registry + '/underscore'
npm.registry.get(rollup, PARAMS, function (er, data) {
t.ifError(er, 'loaded all metadata')
t.deepEqual(data.name, 'underscore')
- fs.stat(getCachePath(rollup), function (er) {
- t.ifError(er, 'underscore rollup cache data written')
- })
})
var scoped = common.registry + '/@bigco%2fsample/1.2.3'
npm.registry.get(scoped, PARAMS, function (er, data) {
t.ifError(er, 'loaded all metadata')
t.equal(data.name, '@bigco/sample')
- fs.stat(getCachePath(scoped), function (er) {
- t.ifError(er, 'scoped cache data written')
- })
})
})
diff --git a/deps/npm/test/tap/gist-short-shortcut-package.js b/deps/npm/test/tap/gist-short-shortcut-package.js
index c15e1df7e2..4074995ee5 100644
--- a/deps/npm/test/tap/gist-short-shortcut-package.js
+++ b/deps/npm/test/tap/gist-short-shortcut-package.js
@@ -28,8 +28,8 @@ test('setup', function (t) {
test('gist-short-shortcut-package', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
- ['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
- ['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
+ ['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs third'],
+ ['ssh://git@gist.github.com/deadbeef.git', 'GitHub gist shortcuts try SSH second']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/gist-short-shortcut.js b/deps/npm/test/tap/gist-short-shortcut.js
index c7d217f9a9..875c30e036 100644
--- a/deps/npm/test/tap/gist-short-shortcut.js
+++ b/deps/npm/test/tap/gist-short-shortcut.js
@@ -26,7 +26,7 @@ test('gist-shortcut', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
- ['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
+ ['ssh://git@gist.github.com/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/gist-shortcut-package.js b/deps/npm/test/tap/gist-shortcut-package.js
index e35ab71e84..dd6f41359e 100644
--- a/deps/npm/test/tap/gist-shortcut-package.js
+++ b/deps/npm/test/tap/gist-shortcut-package.js
@@ -29,7 +29,7 @@ test('gist-shortcut-package', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
- ['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
+ ['ssh://git@gist.github.com/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/gist-shortcut.js b/deps/npm/test/tap/gist-shortcut.js
index 3b48e47009..8ad5ef001c 100644
--- a/deps/npm/test/tap/gist-shortcut.js
+++ b/deps/npm/test/tap/gist-shortcut.js
@@ -26,7 +26,7 @@ test('gist-shortcut', function (t) {
var cloneUrls = [
['git://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try git URLs first'],
['https://gist.github.com/deadbeef.git', 'GitHub gist shortcuts try HTTPS URLs second'],
- ['git@gist.github.com:/deadbeef.git', 'GitHub gist shortcuts try SSH third']
+ ['ssh://git@gist.github.com/deadbeef.git', 'GitHub gist shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/git-npmignore.js b/deps/npm/test/tap/git-npmignore.js
index 6b99bdf1fa..819e0a6285 100644
--- a/deps/npm/test/tap/git-npmignore.js
+++ b/deps/npm/test/tap/git-npmignore.js
@@ -14,6 +14,7 @@ var Dir = Tacks.Dir
var File = Tacks.File
var fixture = new Tacks(Dir({
+ cache: Dir({}),
deps: Dir({
gitch: Dir({
'.npmignore': File(
@@ -41,6 +42,7 @@ var fixture = new Tacks(Dir({
}))
var testdir = resolve(__dirname, path.basename(__filename, '.js'))
+var cachedir = resolve(testdir, 'cache')
var dep = resolve(testdir, 'deps', 'gitch')
var packname = 'gitch-1.0.0.tgz'
var packed = resolve(testdir, packname)
@@ -52,7 +54,12 @@ var expected = [
'.npmignore'
].sort()
-var NPM_OPTS = { cwd: testdir }
+var NPM_OPTS = {
+ cwd: testdir,
+ env: common.newEnv().extend({
+ npm_config_cache: cachedir
+ })
+}
function exec (todo, opts, cb) {
console.log(' # EXEC:', todo)
@@ -134,13 +141,13 @@ function setup (cb) {
common.npm(
[
'--loglevel', 'error',
- 'cache', 'clean'
+ 'cache', 'clean', '--force'
],
NPM_OPTS,
function (er, code, _, stderr) {
if (er) return cb(er)
- if (code) return cb(new Error('npm cache nonzero exit: ' + code))
if (stderr) return cb(new Error('npm cache clean error: ' + stderr))
+ if (code) return cb(new Error('npm cache nonzero exit: ' + code))
which('git', function found (er, gitPath) {
if (er) return cb(er)
diff --git a/deps/npm/test/tap/git-prepare.js b/deps/npm/test/tap/git-prepare.js
new file mode 100644
index 0000000000..1a61056b4b
--- /dev/null
+++ b/deps/npm/test/tap/git-prepare.js
@@ -0,0 +1,181 @@
+'use strict'
+
+const fs = require('fs')
+const path = require('path')
+
+const osenv = require('osenv')
+const rimraf = require('rimraf')
+const test = require('tap').test
+const mr = require('npm-registry-mock')
+
+const npm = require('../../lib/npm.js')
+const common = require('../common-tap.js')
+
+const testdir = path.resolve(__dirname, path.basename(__filename, '.js'))
+const repo = path.join(testdir, 'repo')
+const prefix = path.join(testdir, 'prefix')
+const cache = path.join(testdir, 'cache')
+
+var Tacks = require('tacks')
+var Dir = Tacks.Dir
+var File = Tacks.File
+
+let daemon
+let daemonPID
+let git
+let mockRegistry
+
+process.env.npm_config_prefix = prefix
+
+const fixture = new Tacks(Dir({
+ repo: Dir({}),
+ prefix: Dir({}),
+ cache: Dir({}),
+ deps: Dir({
+ parent: Dir({
+ 'package.json': File({
+ name: 'parent',
+ version: '1.2.3',
+ dependencies: {
+ 'child': 'git://localhost:1234/child.git'
+ }
+ })
+ }),
+ child: Dir({
+ 'package.json': File({
+ name: 'child',
+ version: '1.0.3',
+ main: 'dobuild.js',
+ scripts: {
+ 'prepublish': 'exit 123',
+ 'prepare': 'writer build-artifact'
+ },
+ devDependencies: {
+ writer: 'file:' + path.join(testdir, 'deps', 'writer')
+ }
+ })
+ }),
+ writer: Dir({
+ 'package.json': File({
+ name: 'writer',
+ version: '1.0.0',
+ bin: 'writer.js'
+ }),
+ 'writer.js': File(`#!/usr/bin/env node\n
+ require('fs').writeFileSync(process.argv[2], 'hello, world!')
+ `)
+ })
+ })
+}))
+
+test('setup', function (t) {
+ bootstrap()
+ setup(function (er, r) {
+ t.ifError(er, 'git started up successfully')
+
+ if (!er) {
+ daemon = r[r.length - 2]
+ daemonPID = r[r.length - 1]
+ }
+
+ mr({
+ port: common.port
+ }, function (er, server) {
+ t.ifError(er, 'started mock registry')
+ mockRegistry = server
+
+ t.end()
+ })
+ })
+})
+
+test('install from git repo with prepare script', function (t) {
+ const parent = path.join(testdir, 'deps', 'parent')
+
+ common.npm([
+ 'install',
+ '--no-save',
+ '--registry', common.registry,
+ '--cache', cache,
+ '--loglevel', 'error'
+ ], {
+ cwd: parent
+ }, function (err, code, stdout, stderr) {
+ if (err) { throw err }
+ t.equal(code, 0, 'exited successfully')
+ t.equal(stderr, '', 'no actual output on stderr')
+
+ const target = path.join(parent, 'node_modules', 'child', 'build-artifact')
+ fs.readFile(target, 'utf8', (err, data) => {
+ if (err) { throw err }
+ t.equal(data, 'hello, world!', 'build artifact written for git dep')
+ t.end()
+ })
+ })
+})
+
+test('clean', function (t) {
+ mockRegistry.close()
+ daemon.on('close', function () {
+ cleanup()
+ t.end()
+ })
+ process.kill(daemonPID)
+})
+
+function bootstrap () {
+ fixture.create(testdir)
+}
+
+function setup (cb) {
+ npm.load({
+ prefix: testdir,
+ loglevel: 'silent'
+ }, function () {
+ git = require('../../lib/utils/git.js')
+
+ function startDaemon (cb) {
+ // start git server
+ const d = git.spawn(
+ [
+ 'daemon',
+ '--verbose',
+ '--listen=localhost',
+ '--export-all',
+ '--base-path=.',
+ '--reuseaddr',
+ '--port=1234'
+ ],
+ {
+ cwd: repo,
+ env: process.env
+ }
+ )
+ d.stderr.on('data', childFinder)
+
+ function childFinder (c) {
+ const cpid = c.toString().match(/^\[(\d+)\]/)
+ if (cpid[1]) {
+ this.removeListener('data', childFinder)
+ cb(null, [d, cpid[1]])
+ }
+ }
+ }
+
+ const childPath = path.join(testdir, 'deps', 'child')
+ common.makeGitRepo({
+ path: childPath,
+ commands: [
+ git.chainableExec([
+ 'clone', '--bare', childPath, 'child.git'
+ ], { cwd: repo, env: process.env }),
+ startDaemon
+ ]
+ }, cb)
+ })
+}
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(testdir)
+}
diff --git a/deps/npm/test/tap/github-shortcut-package.js b/deps/npm/test/tap/github-shortcut-package.js
index e1a4b306cc..73385436b7 100644
--- a/deps/npm/test/tap/github-shortcut-package.js
+++ b/deps/npm/test/tap/github-shortcut-package.js
@@ -29,7 +29,7 @@ test('github-shortcut-package', function (t) {
var cloneUrls = [
['git://github.com/foo/private.git', 'GitHub shortcuts try git URLs first'],
['https://github.com/foo/private.git', 'GitHub shortcuts try HTTPS URLs second'],
- ['git@github.com:foo/private.git', 'GitHub shortcuts try SSH third']
+ ['ssh://git@github.com/foo/private.git', 'GitHub shortcuts try SSH third']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/github-shortcut.js b/deps/npm/test/tap/github-shortcut.js
index c0a67d21a4..641d64f3b9 100644
--- a/deps/npm/test/tap/github-shortcut.js
+++ b/deps/npm/test/tap/github-shortcut.js
@@ -1,18 +1,21 @@
'use strict'
-var fs = require('graceful-fs')
-var path = require('path')
-var mkdirp = require('mkdirp')
-var osenv = require('osenv')
-var requireInject = require('require-inject')
-var rimraf = require('rimraf')
-var test = require('tap').test
+const BB = require('bluebird')
-var common = require('../common-tap.js')
+const fs = require('graceful-fs')
+const path = require('path')
-var pkg = path.resolve(__dirname, 'github-shortcut')
+const mkdirp = require('mkdirp')
+const osenv = require('osenv')
+const requireInject = require('require-inject')
+const rimraf = require('rimraf')
+const test = require('tap').test
-var json = {
+const common = require('../common-tap.js')
+
+const pkg = path.resolve(__dirname, 'github-shortcut')
+
+const json = {
name: 'github-shortcut',
version: '0.0.0'
}
@@ -23,38 +26,38 @@ test('setup', function (t) {
})
test('github-shortcut', function (t) {
- var cloneUrls = [
+ const cloneUrls = [
['git://github.com/foo/private.git', 'GitHub shortcuts try git URLs first'],
['https://github.com/foo/private.git', 'GitHub shortcuts try HTTPS URLs second'],
- ['git@github.com:foo/private.git', 'GitHub shortcuts try SSH third']
+ ['ssh://git@github.com/foo/private.git', 'GitHub shortcuts try SSH third']
]
- var npm = requireInject.installGlobally('../../lib/npm.js', {
- 'child_process': {
- 'execFile': function (cmd, args, options, cb) {
- process.nextTick(function () {
- if (args.indexOf('clone') === -1) return cb(null, '', '')
- var cloneUrl = cloneUrls.shift()
+ const npm = requireInject.installGlobally('../../lib/npm.js', {
+ 'pacote/lib/util/git': {
+ 'revs': (repo, opts) => {
+ return BB.resolve().then(() => {
+ const cloneUrl = cloneUrls.shift()
if (cloneUrl) {
- t.is(args[args.length - 2], cloneUrl[0], cloneUrl[1])
+ t.is(repo, cloneUrl[0], cloneUrl[1])
} else {
t.fail('too many attempts to clone')
}
- cb(new Error('execFile mock fails on purpose'))
+ throw new Error('git.revs mock fails on purpose')
})
}
}
})
- var opts = {
+ const opts = {
cache: path.resolve(pkg, 'cache'),
prefix: pkg,
registry: common.registry,
loglevel: 'silent'
}
- t.plan(1 + cloneUrls.length)
+ t.plan(2 + cloneUrls.length)
npm.load(opts, function (err) {
t.ifError(err, 'npm loaded without error')
- npm.commands.install(['foo/private'], function (er, result) {
+ npm.commands.install(['foo/private'], function (err, result) {
+ t.match(err.message, /mock fails on purpose/, 'mocked install failed as expected')
t.end()
})
})
diff --git a/deps/npm/test/tap/gitlab-shortcut-package.js b/deps/npm/test/tap/gitlab-shortcut-package.js
index 335bc4d60a..1dd1ba99fb 100644
--- a/deps/npm/test/tap/gitlab-shortcut-package.js
+++ b/deps/npm/test/tap/gitlab-shortcut-package.js
@@ -28,7 +28,7 @@ test('setup', function (t) {
test('gitlab-shortcut-package', function (t) {
var cloneUrls = [
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second'],
- ['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first']
+ ['ssh://git@gitlab.com/foo/private.git', 'GitLab shortcuts try SSH first']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/gitlab-shortcut.js b/deps/npm/test/tap/gitlab-shortcut.js
index dcba064bc1..6b2bfbc3ed 100644
--- a/deps/npm/test/tap/gitlab-shortcut.js
+++ b/deps/npm/test/tap/gitlab-shortcut.js
@@ -25,7 +25,7 @@ test('setup', function (t) {
test('gitlab-shortcut', function (t) {
var cloneUrls = [
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second'],
- ['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first']
+ ['ssh://git@gitlab.com/foo/private.git', 'GitLab shortcuts try SSH first']
]
var npm = requireInject.installGlobally('../../lib/npm.js', {
'child_process': {
diff --git a/deps/npm/test/tap/install-actions.js b/deps/npm/test/tap/install-actions.js
index 824a31c1be..6ca6e33534 100644
--- a/deps/npm/test/tap/install-actions.js
+++ b/deps/npm/test/tap/install-actions.js
@@ -56,8 +56,10 @@ test('->optdep:a->dep:b', function (t) {
moduleB.parent = tree
t.plan(3)
- actions.postinstall('/', moduleA, mockLog, function (er) {
- t.is(er && er.code, 'ELIFECYCLE', 'Lifecycle failed')
+ return actions.postinstall('/', moduleA, mockLog).then(() => {
+ throw new Error('was not supposed to succeed')
+ }, (err) => {
+ t.is(err && err.code, 'ELIFECYCLE', 'Lifecycle failed')
t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
t.ok(moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
t.end()
@@ -108,8 +110,10 @@ test('->dep:b,->optdep:a->dep:b', function (t) {
moduleB.parent = tree
t.plan(3)
- actions.postinstall('/', moduleA, mockLog, function (er) {
- t.ok(er && er.code === 'ELIFECYCLE', 'Lifecycle failed')
+ return actions.postinstall('/', moduleA, mockLog).then(() => {
+ throw new Error('was not supposed to succeed')
+ }, (err) => {
+ t.ok(err && err.code === 'ELIFECYCLE', 'Lifecycle failed')
t.ok(moduleA.failed, 'moduleA (optional dep) is marked failed')
t.ok(!moduleB.failed, 'moduleB (direct dep of moduleA) is marked as failed')
t.end()
diff --git a/deps/npm/test/tap/install-at-locally.js b/deps/npm/test/tap/install-at-locally.js
index 8745c4d60e..fa0190ceb3 100644
--- a/deps/npm/test/tap/install-at-locally.js
+++ b/deps/npm/test/tap/install-at-locally.js
@@ -10,7 +10,7 @@ var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'install-at-locally')
-var EXEC_OPTS = { cwd: pkg }
+var EXEC_OPTS = { cwd: pkg, stdio: [0, 1, 2] }
var json = {
name: 'install-at-locally-mock',
@@ -26,8 +26,8 @@ test('\'npm install ./package@1.2.3\' should install local pkg', function (t) {
var target = './package@1.2.3'
setup(target)
common.npm(['install', '--loglevel=silent', target], EXEC_OPTS, function (err, code) {
+ if (err) throw err
var p = path.resolve(pkg, 'node_modules/install-at-locally-mock/package.json')
- t.ifError(err, 'install local package successful')
t.equal(code, 0, 'npm install exited with code')
t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
t.end()
@@ -38,8 +38,8 @@ test('\'npm install install/at/locally@./package@1.2.3\' should install local pk
var target = 'install/at/locally@./package@1.2.3'
setup(target)
common.npm(['install', target], EXEC_OPTS, function (err, code) {
+ if (err) throw err
var p = path.resolve(pkg, 'node_modules/install-at-locally-mock/package.json')
- t.ifError(err, 'install local package in explicit directory successful')
t.equal(code, 0, 'npm install exited with code')
t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
t.end()
diff --git a/deps/npm/test/tap/install-noargs-dev.js b/deps/npm/test/tap/install-noargs-dev.js
index f16a7498f5..ec9c7e3687 100644
--- a/deps/npm/test/tap/install-noargs-dev.js
+++ b/deps/npm/test/tap/install-noargs-dev.js
@@ -44,6 +44,7 @@ test('install noargs installs devDependencies', function (t) {
[
'--registry', common.registry,
'--loglevel', 'silent',
+ '--no-save',
'install'
],
EXEC_OPTS,
@@ -70,6 +71,7 @@ test('install noargs installs updated devDependencies', function (t) {
[
'--registry', common.registry,
'--loglevel', 'silent',
+ '--no-save',
'install'
],
EXEC_OPTS,
diff --git a/deps/npm/test/tap/install-report-just-installed.js b/deps/npm/test/tap/install-report-just-installed.js
index fb3bc65dbd..0a2cde2562 100644
--- a/deps/npm/test/tap/install-report-just-installed.js
+++ b/deps/npm/test/tap/install-report-just-installed.js
@@ -50,7 +50,7 @@ test('setup', function (t) {
})
test('install-report', function (t) {
- common.npm(['install', '--json', 'b-src'], {cwd: testdir}, function (err, code, stdout, stderr) {
+ common.npm(['install', '--no-save', '--json', './b-src'], {cwd: testdir}, function (err, code, stdout, stderr) {
if (err) throw err
t.is(code, 0, 'installed successfully')
t.is(stderr, '', 'no warnings')
@@ -63,9 +63,8 @@ test('install-report', function (t) {
t.skip(2)
return t.end()
}
- var depNames = Object.keys(report.dependencies)
- t.is(depNames.length, 1, 'one dependency reported as installed')
- t.ok(report.dependencies.b, 'that dependency was `b`')
+ t.is(report.added.length, 1, 'one dependency reported as installed')
+ t.match(report.added, [{name: 'b'}], 'that dependency was `b`')
t.end()
})
})
diff --git a/deps/npm/test/tap/install-save-local.js b/deps/npm/test/tap/install-save-local.js
index 640ebfef50..f9db76355e 100644
--- a/deps/npm/test/tap/install-save-local.js
+++ b/deps/npm/test/tap/install-save-local.js
@@ -67,7 +67,7 @@ test('\'npm install --save local/path\' should save to package.json', function (
[
'--loglevel', 'silent',
'--save',
- 'install', 'package-local-dependency'
+ 'install', 'package-local-dependency/'
],
EXEC_OPTS,
function (err, code) {
@@ -125,7 +125,7 @@ test('\'npm install --save-dev local/path\' should save to package.json', functi
[
'--loglevel', 'silent',
'--save-dev',
- 'install', 'package-local-dev-dependency'
+ 'install', 'package-local-dev-dependency/'
],
EXEC_OPTS,
function (err, code) {
diff --git a/deps/npm/test/tap/install-shrinkwrapped-git.js b/deps/npm/test/tap/install-shrinkwrapped-git.js
index 34875ffb65..f697980de9 100644
--- a/deps/npm/test/tap/install-shrinkwrapped-git.js
+++ b/deps/npm/test/tap/install-shrinkwrapped-git.js
@@ -50,12 +50,10 @@ test('shrinkwrapped git dependency got updated', function (t) {
chain([
// Install & shrinkwrap child package's first commit
[npm.commands.install, ['git://localhost:1234/child.git#' + refs[0]]],
- [npm.commands.shrinkwrap, []],
// Backup node_modules with the first commit
[fs.rename, parentNodeModulesPath, outdatedNodeModulesPath],
// Install & shrinkwrap child package's second commit
[npm.commands.install, ['git://localhost:1234/child.git#' + refs[1]]],
- [npm.commands.shrinkwrap, []],
// Restore node_modules with the first commit
[rimraf, parentNodeModulesPath],
[fs.rename, outdatedNodeModulesPath, parentNodeModulesPath],
diff --git a/deps/npm/test/tap/it.js b/deps/npm/test/tap/it.js
index 0381289709..b0dddb8f91 100644
--- a/deps/npm/test/tap/it.js
+++ b/deps/npm/test/tap/it.js
@@ -35,7 +35,7 @@ test('run up the mock registry', function (t) {
test('npm install-test', function (t) {
setup()
- common.npm(['install-test', '--registry=' + common.registry], { cwd: pkg }, function (err, code, stdout, stderr) {
+ common.npm(['install-test', '--no-shrinkwrap', '--registry=' + common.registry], { cwd: pkg }, function (err, code, stdout, stderr) {
if (err) throw err
t.equal(code, 0, 'command ran without error')
t.ok(statSync(installed), 'package was installed')
diff --git a/deps/npm/test/tap/ls-depth-cli.js b/deps/npm/test/tap/ls-depth-cli.js
index 87eafced2c..2b1bfa42a8 100644
--- a/deps/npm/test/tap/ls-depth-cli.js
+++ b/deps/npm/test/tap/ls-depth-cli.js
@@ -2,7 +2,8 @@ var fs = require('graceful-fs')
var path = require('path')
var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
+var Bluebird = require('bluebird')
+var mr = Bluebird.promisify(require('npm-registry-mock'))
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
@@ -11,7 +12,13 @@ var common = require('../common-tap')
var pkg = path.resolve(__dirname, 'ls-depth-cli')
-var EXEC_OPTS = { cwd: pkg }
+var EXEC_OPTS = {
+ cwd: pkg,
+ env: common.newEnv().extend({
+ npm_config_registry: common.registry
+ }),
+ stdio: [0, 'pipe', 2]
+}
var json = {
name: 'ls-depth-cli',
@@ -28,43 +35,27 @@ test('setup', function (t) {
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
)
- mr({ port: common.port }, function (er, s) {
- common.npm(
- [
- '--registry', common.registry,
- 'install'
- ],
- EXEC_OPTS,
- function (er, c) {
- t.ifError(er, 'setup installation ran without issue')
- t.equal(c, 0)
- s.close()
- t.end()
- }
- )
+ return mr({ port: common.port }).then((s) => {
+ return common.npm(['install'], EXEC_OPTS).spread((c) => {
+ t.is(c, 0)
+ }).finally(() => s.close())
})
})
test('npm ls --depth=0', function (t) {
- common.npm(
- ['ls', '--depth=0'],
- EXEC_OPTS,
- function (er, c, out) {
- t.ifError(er, 'npm ls ran without issue')
- t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.doesNotHave(
- out,
- /test-package@0\.0\.0/,
- 'output not contains test-package@0.0.0'
- )
- t.end()
- }
- )
+ return common.npm(['ls', '--depth=0'], EXEC_OPTS).spread((c, out) => {
+ t.equal(c, 0, 'ls ran without raising error code')
+ t.has(
+ out,
+ /test-package-with-one-dep@0\.0\.0/,
+ 'output contains test-package-with-one-dep@0.0.0'
+ )
+ t.doesNotHave(
+ out,
+ /test-package@0\.0\.0/,
+ 'output not contains test-package@0.0.0'
+ )
+ })
})
test('npm ls --depth=1', function (t) {
@@ -120,16 +111,16 @@ test('npm ls --depth=0 --json', function (t) {
function (er, c, out) {
t.ifError(er, 'npm ls ran without issue')
t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.doesNotHave(
- out,
- /test-package@0\.0\.0/,
- 'output not contains test-package@0.0.0'
- )
+ t.has(JSON.parse(out), {
+ 'name': 'ls-depth-cli',
+ 'version': '0.0.0',
+ 'dependencies': {
+ 'test-package-with-one-dep': {
+ 'version': '0.0.0',
+ 'resolved': 'http://localhost:1337/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz'
+ }
+ }
+ })
t.end()
}
)
@@ -144,16 +135,22 @@ test('npm ls --depth=Infinity --json', function (t) {
function (er, c, out) {
t.ifError(er, 'npm ls ran without issue')
t.equal(c, 0, 'ls ran without raising error code')
- t.has(
- out,
- /test-package-with-one-dep@0\.0\.0/,
- 'output contains test-package-with-one-dep@0.0.0'
- )
- t.has(
- out,
- /test-package@0\.0\.0/,
- 'output contains test-package@0.0.0'
- )
+ t.has(JSON.parse(out), {
+ 'name': 'ls-depth-cli',
+ 'version': '0.0.0',
+ 'dependencies': {
+ 'test-package-with-one-dep': {
+ 'version': '0.0.0',
+ 'resolved': 'http://localhost:1337/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz',
+ 'dependencies': {
+ 'test-package': {
+ 'version': '0.0.0',
+ 'resolved': 'http://localhost:1337/test-package/-/test-package-0.0.0.tgz'
+ }
+ }
+ }
+ }
+ })
t.end()
}
)
diff --git a/deps/npm/test/tap/ls-depth-unmet.js b/deps/npm/test/tap/ls-depth-unmet.js
index 6511cdb333..0386ab249d 100644
--- a/deps/npm/test/tap/ls-depth-unmet.js
+++ b/deps/npm/test/tap/ls-depth-unmet.js
@@ -35,7 +35,7 @@ test('setup', function (t) {
common.npm(
[
'--registry', common.registry,
- 'install', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep'
+ 'install', '--no-save', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep'
],
EXEC_OPTS,
function (er, c) {
diff --git a/deps/npm/test/tap/ls-l-depth-0.js b/deps/npm/test/tap/ls-l-depth-0.js
index 3958520943..e9c2374aad 100644
--- a/deps/npm/test/tap/ls-l-depth-0.js
+++ b/deps/npm/test/tap/ls-l-depth-0.js
@@ -2,7 +2,8 @@ var cat = require('graceful-fs').writeFileSync
var resolve = require('path').resolve
var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
+var Bluebird = require('bluebird')
+var mr = Bluebird.promisify(require('npm-registry-mock'))
var rimraf = require('rimraf')
var test = require('tap').test
var tmpdir = require('osenv').tmpdir
@@ -21,6 +22,7 @@ var expected =
' an inexplicably hostile sample package\n' +
' git+https://github.com/npm/glo.ck.git\n' +
' https://glo.ck\n' +
+ ' file:glock-1.8.7.tgz\n' +
'\n'
var server
@@ -39,12 +41,16 @@ var fixture = {
}
}
+var deppack
+
test('setup', function (t) {
setup()
- mr({ port: common.port }, function (er, s) {
+ return mr({ port: common.port }).then((s) => {
server = s
-
- t.end()
+ return common.npm(['pack', dep], EXEC_OPTS)
+ }).spread((code, stdout) => {
+ t.is(code, 0, 'pack')
+ deppack = stdout.trim()
})
})
@@ -53,19 +59,18 @@ test('#6311: npm ll --depth=0 duplicates listing', function (t) {
[
'--loglevel', 'silent',
'--registry', common.registry,
- '--unicode=true',
- 'install', dep
+ '--parseable',
+ 'install', deppack
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
- t.ifError(err, 'npm install ran without error')
+ if (err) throw err
t.notOk(code, 'npm install exited cleanly')
- t.notOk(stderr, 'npm install ran silently')
+ t.is(stderr, '', 'npm install ran silently')
t.equal(
stdout.trim(),
- resolve(__dirname, 'ls-l-depth-0') +
- '\n└─┬ glock@1.8.7 ' +
- '\n └── underscore@1.5.1',
+ 'add\tunderscore\t1.5.1\tnode_modules/underscore\t\t\n' +
+ 'add\tglock\t1.8.7\tnode_modules/glock',
'got expected install output'
)
@@ -78,9 +83,9 @@ test('#6311: npm ll --depth=0 duplicates listing', function (t) {
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
- t.ifError(err, 'npm ll ran without error')
+ if (err) throw err
t.is(code, 0, 'npm ll exited cleanly')
- t.notOk(stderr, 'npm ll ran silently')
+ t.is(stderr, '', 'npm ll ran silently')
t.equal(
stdout,
expected,
diff --git a/deps/npm/test/tap/optional-metadep-rollback-collision.js b/deps/npm/test/tap/optional-metadep-rollback-collision.js
index bc1bccd16e..862e6e8c72 100644
--- a/deps/npm/test/tap/optional-metadep-rollback-collision.js
+++ b/deps/npm/test/tap/optional-metadep-rollback-collision.js
@@ -191,6 +191,7 @@ test('go go test racer', function (t) {
'--prefix', pkg,
'--fetch-retries', '0',
'--loglevel', 'silent',
+ '--parseable',
'--cache', cache,
'install'
],
diff --git a/deps/npm/test/tap/outdated-long.js b/deps/npm/test/tap/outdated-long.js
index 8fdf3057bf..6ea5e6e2c4 100644
--- a/deps/npm/test/tap/outdated-long.js
+++ b/deps/npm/test/tap/outdated-long.js
@@ -39,7 +39,7 @@ test('it should not throw', function (t) {
var output = []
var expOut = [
- path.resolve(pkg, 'node_modules', 'underscore'),
+ 'add\tunderscore\t1.3.1\tnode_modules/underscore\t\t',
path.resolve(pkg, 'node_modules', 'underscore') +
':underscore@1.3.1' +
':underscore@1.3.1' +
@@ -79,7 +79,6 @@ test('it should not throw', function (t) {
t.is(process.exitCode, 1, 'exit code set to 1')
process.exitCode = 0
console.log = originalLog
-
t.same(output, expOut)
t.same(d, expData)
diff --git a/deps/npm/test/tap/override-bundled.js b/deps/npm/test/tap/override-bundled.js
index e23c8255c4..cf6049a128 100644
--- a/deps/npm/test/tap/override-bundled.js
+++ b/deps/npm/test/tap/override-bundled.js
@@ -1,4 +1,5 @@
'use strict'
+var Bluebird = require('bluebird')
var test = require('tap').test
var fs = require('fs')
var mkdirp = require('mkdirp')
@@ -9,68 +10,82 @@ var common = require('../common-tap.js')
var testname = path.basename(__filename, '.js')
var testdir = path.resolve(__dirname, testname)
var testmod = path.resolve(testdir, 'top-test')
+var testtgz = testmod + '-1.0.0.tgz'
var bundleupdatesrc = path.resolve(testmod, 'bundle-update')
+var bundleupdatetgz = bundleupdatesrc + '-1.0.0.tgz'
var bundleupdateNEW = path.resolve(bundleupdatesrc, 'NEW')
var bundleupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-update', 'NEW')
var bundleupdatebad = path.resolve(testmod, 'node_modules', 'bundle-update')
var bundlekeepsrc = path.resolve(testmod, 'bundle-keep')
+var bundlekeeptgz = bundlekeepsrc + '-1.0.0.tgz'
var bundlekeep = path.resolve(testmod, 'node_modules', 'bundle-keep')
var bundlekeepOLD = path.resolve(bundlekeep, 'OLD')
var bundlekeepOLDpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-keep', 'OLD')
var bundledeepsrc = path.resolve(testmod, 'bundle-deep')
+var bundledeeptgz = bundledeepsrc + '-1.0.0.tgz'
var bundledeep = path.resolve(testmod, 'node_modules', 'bundle-deep')
var bundledeepOLD = path.resolve(bundledeep, 'OLD')
var bundledeepOLDpostinstall = path.resolve(testdir, 'node_modules', 'top-test', 'node_modules', 'bundle-deep', 'OLD')
var bundledeepupdatesrc = path.resolve(testmod, 'bundle-deep-update')
+var bundledeepupdatetgz = bundledeepupdatesrc + '-1.0.0.tgz'
var bundledeepupdate = path.resolve(bundledeep, 'node_modules', 'bundle-deep-update')
var bundledeepupdateNEW = path.resolve(bundledeepupdatesrc, 'NEW')
var bundledeepupdateNEWpostinstall = path.resolve(testdir, 'node_modules', 'top-test',
'node_modules', 'bundle-deep', 'node_modules', 'bundle-deep-update', 'NEW')
var testjson = {
- dependencies: {'top-test': 'file:top-test/'}
+ dependencies: {'top-test': 'file:' + testtgz}
}
var testmodjson = {
name: 'top-test',
version: '1.0.0',
dependencies: {
- 'bundle-update': bundleupdatesrc,
- 'bundle-keep': bundlekeepsrc,
- 'bundle-deep': bundledeepsrc
+ 'bundle-update': bundleupdatetgz,
+ 'bundle-keep': bundlekeeptgz,
+ 'bundle-deep': bundledeeptgz
},
- bundledDependencies: ['bundle-update', 'bundle-keep', 'bundle-deep']
+ bundledDependencies: ['bundle-update', 'bundle-keep', 'bundle-deep'],
+ files: ['OLD', 'NEW']
}
var bundlejson = {
name: 'bundle-update',
- version: '1.0.0'
+ version: '1.0.0',
+ files: ['OLD', 'NEW']
+
}
var bundlekeepjson = {
name: 'bundle-keep',
version: '1.0.0',
_requested: {
- rawSpec: bundlekeepsrc
- }
+ rawSpec: bundlekeeptgz
+ },
+ files: ['OLD', 'NEW']
+
}
var bundledeepjson = {
name: 'bundle-deep',
version: '1.0.0',
dependencies: {
- 'bundle-deep-update': bundledeepupdatesrc
+ 'bundle-deep-update': bundledeepupdatetgz
},
_requested: {
- rawSpec: bundledeepsrc
- }
+ rawSpec: bundledeeptgz
+ },
+ files: ['OLD', 'NEW']
+
}
var bundledeepupdatejson = {
version: '1.0.0',
- name: 'bundle-deep-update'
+ name: 'bundle-deep-update',
+ files: ['OLD', 'NEW']
+
}
function writepjs (dir, content) {
@@ -115,13 +130,28 @@ function cleanup () {
test('setup', function (t) {
cleanup()
setup()
- t.end()
+ return Bluebird.all([
+ common.npm(['pack', bundleupdatesrc], {cwd: path.dirname(bundleupdatetgz), stdio: 'inherit'}),
+ common.npm(['pack', bundlekeepsrc], {cwd: path.dirname(bundlekeeptgz), stdio: 'inherit'}),
+ common.npm(['pack', bundledeepupdatesrc], {cwd: path.dirname(bundledeepupdatetgz), stdio: 'inherit'})
+ ]).map((result) => result[0]).spread((bundleupdate, bundlekeep, bundledeepupdate) => {
+ t.is(bundleupdate, 0, 'bundleupdate')
+ t.is(bundlekeep, 0, 'bundlekeep')
+ t.is(bundledeepupdate, 0, 'bundledeepupdate')
+ }).then(() => {
+ return common.npm(['pack', bundledeepsrc], {cwd: path.dirname(bundledeeptgz), stdio: 'inherit'})
+ }).spread((code) => {
+ t.is(code, 0, 'bundledeep')
+ return common.npm(['pack', testmod], {cwd: path.dirname(testtgz), stdio: 'inherit'})
+ }).spread((code) => {
+ t.is(code, 0, 'testmod')
+ })
})
test('bundled', function (t) {
- common.npm(['install', '--loglevel=warn'], {cwd: testdir}, function (err, code, stdout, stderr) {
+ common.npm(['install', '--loglevel=verbose'], {cwd: testdir}, function (err, code, stdout, stderr) {
if (err) throw err
- t.plan(8)
+ t.plan(9)
t.is(code, 0, 'npm itself completed ok')
// This tests that after the install we have a freshly installed version
@@ -133,8 +163,9 @@ test('bundled', function (t) {
// _things_ to it. Things like chmod in particular, which in turn results
// in the dreaded ENOENT errors.
t.like(stderr, new RegExp('npm WARN ' + testname), "didn't stomp on other warnings")
- t.like(stderr, /npm WARN.*bundle-update/, 'included update warning about bundled dep')
- t.like(stderr, /npm WARN.*bundle-deep-update/, 'included update warning about deeply bundled dep')
+ t.like(stderr, /npm verb.*bundle-update/, 'included update warning about bundled dep')
+ t.like(stderr, /npm verb.*bundle-deep-update/, 'included update warning about deeply bundled dep')
+ t.like(stderr, /npm WARN top-test@1\.0\.0 had bundled packages that do not match/, 'single grouped warning')
fs.stat(bundleupdateNEWpostinstall, function (missing) {
t.ok(!missing, 'package.json overrode bundle')
})
diff --git a/deps/npm/test/tap/owner.js b/deps/npm/test/tap/owner.js
index 4bef1a0d87..0be88284d9 100644
--- a/deps/npm/test/tap/owner.js
+++ b/deps/npm/test/tap/owner.js
@@ -1,11 +1,22 @@
var mr = require('npm-registry-mock')
var test = require('tap').test
+var path = require('path')
+var mkdirp = require('mkdirp')
+var rimraf = require('rimraf')
var common = require('../common-tap.js')
+var basedir = path.join(__dirname, path.basename(__filename, '.js'))
+var cachedir = path.join(basedir, 'cache')
var server
-var EXEC_OPTS = {}
+var EXEC_OPTS = {
+ cwd: basedir,
+ stdio: [0, 'pipe', 2],
+ env: common.newEnv().extend({
+ npm_config_cache: cachedir
+ })
+}
var jashkenas = {
name: 'jashkenas',
@@ -63,28 +74,18 @@ function mocks (server) {
}
test('setup', function (t) {
- common.npm(
- [
- '--loglevel', 'silent',
- 'cache', 'clean'
- ],
- EXEC_OPTS,
- function (err, code) {
- t.ifError(err, 'npm cache clean ran without error')
- t.notOk(code, 'npm cache clean exited cleanly')
-
- mr({ port: common.port, plugin: mocks }, function (er, s) {
- server = s
- t.end()
- })
- }
- )
+ cleanup()
+ mkdirp.sync(cachedir)
+ mr({ port: common.port, plugin: mocks }, function (er, s) {
+ server = s
+ t.end()
+ })
})
test('npm owner add', function (t) {
common.npm(
[
- '--loglevel', 'silent',
+ '--loglevel', 'warn',
'--registry', common.registry,
'owner', 'add', 'othiym23', 'underscore'
],
@@ -159,5 +160,10 @@ test('npm owner rm', function (t) {
test('cleanup', function (t) {
server.close()
+ cleanup()
t.end()
})
+
+function cleanup () {
+ rimraf.sync(basedir)
+}
diff --git a/deps/npm/test/tap/prepublish.js b/deps/npm/test/tap/prepublish.js
index ef55d79b3b..18bfe5f22a 100644
--- a/deps/npm/test/tap/prepublish.js
+++ b/deps/npm/test/tap/prepublish.js
@@ -59,7 +59,7 @@ test('prepublish deprecation warning on `npm pack`', function (t) {
t.equal(code, 0, 'pack finished successfully')
t.ifErr(err, 'pack finished successfully')
- t.match(stderr, /`prepublish` scripts will run only for `npm publish`/)
+ t.match(stderr, /`prepublish` scripts are deprecated/)
var c = stdout.trim()
var regex = new RegExp('' +
'> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n' +
diff --git a/deps/npm/test/tap/prune.js b/deps/npm/test/tap/prune.js
index ef69dc88b9..4fe586359e 100644
--- a/deps/npm/test/tap/prune.js
+++ b/deps/npm/test/tap/prune.js
@@ -10,7 +10,7 @@ var test = require('tap').test
var common = require('../common-tap')
var server
-var pkg = path.resolve(__dirname, 'prune')
+var pkg = path.resolve(__dirname, path.basename(__filename, '.js'))
var cache = path.resolve(pkg, 'cache')
var json = {
@@ -52,7 +52,7 @@ test('npm install', function (t) {
'--loglevel', 'silent',
'--production', 'false'
], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'install finished successfully')
+ if (err) throw err
t.notOk(code, 'exit ok')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.end()
@@ -64,55 +64,57 @@ test('npm install test-package', function (t) {
'install', 'test-package',
'--cache', cache,
'--registry', common.registry,
+ '--no-save',
'--loglevel', 'silent',
'--production', 'false'
], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'install finished successfully')
+ if (err) throw err
t.notOk(code, 'exit ok')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.end()
})
})
-test('verify installs', function (t) {
+test('setup: verify installs', function (t) {
var dirs = fs.readdirSync(pkg + '/node_modules').sort()
t.same(dirs, [ 'test-package', 'mkdirp', 'underscore' ].sort())
t.end()
})
-test('npm prune', function (t) {
+test('dev: npm prune', function (t) {
common.npm([
'prune',
'--loglevel', 'silent',
'--production', 'false'
], EXEC_OPTS, function (err, code, stdout, stderr) {
- t.ifErr(err, 'prune finished successfully')
+ if (err) throw err
t.notOk(code, 'exit ok')
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
t.end()
})
})
-test('verify installs', function (t) {
+test('dev: verify installs', function (t) {
var dirs = fs.readdirSync(pkg + '/node_modules').sort()
t.same(dirs, [ 'mkdirp', 'underscore' ])
t.end()
})
-test('npm prune', function (t) {
+test('production: npm prune', function (t) {
common.npm([
'prune',
'--loglevel', 'silent',
+ '--parseable',
'--production'
- ], EXEC_OPTS, function (err, code, stderr) {
- t.ifErr(err, 'prune finished successfully')
+ ], EXEC_OPTS, function (err, code, stdout) {
+ if (err) throw err
t.notOk(code, 'exit ok')
- t.equal(stderr, '- mkdirp@0.3.5 node_modules/mkdirp\n')
+ t.equal(stdout.trim(), 'remove\tmkdirp\t0.3.5\tnode_modules/mkdirp')
t.end()
})
})
-test('verify installs', function (t) {
+test('pruduction: verify installs', function (t) {
var dirs = fs.readdirSync(pkg + '/node_modules').sort()
t.same(dirs, [ 'underscore' ])
t.end()
diff --git a/deps/npm/test/tap/retry-on-stale-cache.js b/deps/npm/test/tap/retry-on-stale-cache.js
index 3a7f5c206c..df6d7c2db3 100644
--- a/deps/npm/test/tap/retry-on-stale-cache.js
+++ b/deps/npm/test/tap/retry-on-stale-cache.js
@@ -163,10 +163,11 @@ test('setup new server', function (t) {
test('install new version', function (t) {
common.npm(config.concat([
- '--cache-min', 'Infinity',
+ '--prefer-offline',
'install', 'good-night@1.0.0'
- ]), {stdio: 'inherit'}, function (err, code) {
+ ]), {}, function (err, code, stdout, stderr) {
if (err) throw err
+ t.equal(stderr, '', 'no error output')
t.is(code, 0, 'install succeeded')
t.end()
@@ -176,13 +177,14 @@ test('install new version', function (t) {
test('install does not hit server again', function (t) {
// The mock server route definitions ensure we don't hit the server again
common.npm(config.concat([
- '--cache-min', 'Infinity',
+ '--prefer-offline',
+ '--parseable',
'install', 'good-night'
]), {stdio: [0, 'pipe', 2]}, function (err, code, stdout) {
if (err) throw err
t.is(code, 0, 'install succeeded')
- t.match(stdout, /@1\.0\.0/, 'installed latest version')
+ t.match(stdout, /^update\tgood-night\t1.0.0\t/, 'installed latest version')
server.done()
t.end()
})
diff --git a/deps/npm/test/tap/search.js b/deps/npm/test/tap/search.js
index f389670a42..3568170de1 100644
--- a/deps/npm/test/tap/search.js
+++ b/deps/npm/test/tap/search.js
@@ -62,7 +62,7 @@ test('spits out a useful error when no cache nor network', function (t) {
], {}, function (err, code, stdout, stderr) {
if (err) throw err
t.equal(code, 1, 'non-zero exit code')
- t.equal(stdout, '', 'no stdout output')
+ t.match(JSON.parse(stdout).error.summary, /No search sources available/)
t.match(stderr, /No search sources available/, 'useful error')
t.done()
})
diff --git a/deps/npm/test/tap/shared-linked.js b/deps/npm/test/tap/shared-linked.js
index 63c2538da1..0e2b462789 100644
--- a/deps/npm/test/tap/shared-linked.js
+++ b/deps/npm/test/tap/shared-linked.js
@@ -27,6 +27,7 @@ var optimist = Dir({
minimist: Dir({
'package.json': File({
_shasum: 'd7aa327bcecf518f9106ac6b8f003fa3bcea8566',
+ _resolve: 'foo',
name: 'minimist',
version: '0.0.5'
})
@@ -34,6 +35,7 @@ var optimist = Dir({
wordwrap: Dir({
'package.json': File({
_shasum: 'b79669bb42ecb409f83d583cad52ca17eaa1643f',
+ _resolve: 'foo',
name: 'wordwrap',
version: '0.0.2'
})
@@ -130,15 +132,14 @@ test('shared-linked', function (t) {
'--unicode', 'false'
]
- common.npm(config.concat(['install', '--dry-run']), options, function (err, code, stdout, stderr) {
+ 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 expected =
- 'bug@10800.0.0 ' + bugdir + '\n' +
- '`-- optimist@0.6.0\n' +
- ' +-- minimist@0.0.5\n' +
- ' `-- wordwrap@0.0.2'
+ 'add\tminimist\t0.0.5\tnode_modules/minimist\n' +
+ 'add\twordwrap\t0.0.2\tnode_modules/wordwrap\n' +
+ 'add\toptimist\t0.6.0\tnode_modules/optimist'
t.is(got, expected, 'just an optimist install please')
server.done()
t.end()
diff --git a/deps/npm/test/tap/shrinkwrap-default-arg-ver.js b/deps/npm/test/tap/shrinkwrap-default-arg-ver.js
deleted file mode 100644
index d87bc92391..0000000000
--- a/deps/npm/test/tap/shrinkwrap-default-arg-ver.js
+++ /dev/null
@@ -1,104 +0,0 @@
-'use strict'
-var path = require('path')
-var fs = require('graceful-fs')
-var test = require('tap').test
-var Tacks = require('tacks')
-var File = Tacks.File
-var Dir = Tacks.Dir
-var common = require('../common-tap.js')
-var mr = require('npm-registry-mock')
-
-var testdir = path.join(__dirname, path.basename(__filename, '.js'))
-var config = [
- '--loglevel=error',
- '--registry=' + common.registry,
- '--cache=' + path.join(testdir, 'cache')
-]
-
-var fixture = new Tacks(
- Dir({
- 'cache': Dir(),
- 'npm-shrinkwrap.json': File({
- name: 'shrinkwrap-default-arg-ver',
- version: '1.0.0',
- dependencies: {
- underscore: {
- version: '1.3.1',
- from: 'mod1@>=1.3.1 <2.0.0',
- resolved: common.registry + '/underscore/-/underscore-1.3.1.tgz'
- }
- }
- }),
- 'package.json': File({
- name: 'shrinkwrap-default-arg-ver',
- version: '1.0.0',
- dependencies: {
- underscore: '^1.3.1'
- }
- })
- })
-)
-var installed = path.join(testdir, 'node_modules', 'underscore', 'package.json')
-
-function setup () {
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-var server
-test('setup', function (t) {
- cleanup()
- setup()
- mr({port: common.port}, function (er, s) {
- if (er) throw er
- server = s
- t.end()
- })
-})
-
-function exists (file) {
- try {
- fs.statSync(file)
- return true
- } catch (ex) {
- return false
- }
-}
-test('shrinkwrap-default-arg-version', function (t) {
- // When this feature was malfunctioning npm would select the version of
- // `mod1` from the `package.json` instead of the `npm-shrinkwrap.json`,
- // which in this case would mean trying the registry instead of installing
- // from a local folder.
- common.npm(config.concat(['install', 'underscore']), {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'installed ok')
- t.ok(exists(path.join(testdir, 'node_modules', 'underscore')), 'underscore installed')
- var pjson = JSON.parse(fs.readFileSync(installed))
- t.is(pjson.version, '1.3.1', 'got shrinkwrap version')
- t.end()
- })
-})
-
-test('can-override', function (t) {
- common.npm(config.concat(['install', 'underscore@latest']), {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.is(code, 0, 'installed ok')
- t.ok(exists(path.join(testdir, 'node_modules', 'underscore')), 'underscore installed')
- var pjson = JSON.parse(fs.readFileSync(installed))
- t.is(pjson.version, '1.5.1', 'got latest version')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- server.close()
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/shrinkwrap-default-dev.js b/deps/npm/test/tap/shrinkwrap-default-dev.js
index 6b1aa181e1..5c8929a43d 100644
--- a/deps/npm/test/tap/shrinkwrap-default-dev.js
+++ b/deps/npm/test/tap/shrinkwrap-default-dev.js
@@ -21,7 +21,7 @@ var conf = {
npm_config_tmp: tmpdir,
npm_config_prefix: globaldir,
npm_config_registry: common.registry,
- npm_config_loglevel: 'warn'
+ npm_config_loglevel: 'error'
})
}
@@ -61,11 +61,6 @@ var shrinkwrapWithDev = {
}
}
}
-var shrinkwrapWithoutDev = {
- name: 'shrinkwrap-default-dev',
- version: '1.0.0',
- dependencies: {}
-}
function setup () {
cleanup()
@@ -88,33 +83,7 @@ test('shrinkwrap-default-dev', function (t) {
t.comment(stdout.trim())
t.comment(stderr.trim())
var swrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
- t.isDeeply(swrap, shrinkwrapWithDev, 'Shrinkwrap included dev deps by default')
- t.done()
- })
-})
-
-test('shrinkwrap-only-prod', function (t) {
- fs.unlinkSync(shrinkwrapPath)
- common.npm(['shrinkwrap', '--only=prod'], 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())
- var swrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
- t.isDeeply(swrap, shrinkwrapWithoutDev, 'Shrinkwrap did not include dev deps with --only=prod')
- t.done()
- })
-})
-
-test('shrinkwrap-production', function (t) {
- fs.unlinkSync(shrinkwrapPath)
- common.npm(['shrinkwrap', '--production'], 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())
- var swrap = JSON.parse(fs.readFileSync(shrinkwrapPath))
- t.isDeeply(swrap, shrinkwrapWithoutDev, 'Shrinkwrap did not include dev deps with --production')
+ t.isDeeply(swrap.dependencies, shrinkwrapWithDev.dependencies, 'Shrinkwrap included dev deps by default')
t.done()
})
})
diff --git a/deps/npm/test/tap/shrinkwrap-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
index 3328134629..79d3b7cd0f 100644
--- a/deps/npm/test/tap/shrinkwrap-dev-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-dev-dependency.js
@@ -22,13 +22,13 @@ var desired = {
dependencies: {
request: {
version: '0.9.0',
- from: 'request@0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz'
+ resolved: common.registry + '/request/-/request-0.9.0.tgz',
+ integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
},
underscore: {
version: '1.3.1',
- from: 'underscore@1.3.1',
- resolved: common.registry + '/underscore/-/underscore-1.3.1.tgz'
+ resolved: common.registry + '/underscore/-/underscore-1.3.1.tgz',
+ integrity: 'sha1-bLiq0Od+tdu/tUsivNhpcwnPlkE='
}
}
}
@@ -79,7 +79,7 @@ test("shrinkwrap doesn't strip out the dependency", function (t) {
} catch (ex) {
t.comment(ex)
}
- t.deepEqual(results, desired)
+ t.deepEqual(results.dependencies, desired.dependencies)
s.close()
t.end()
})
diff --git a/deps/npm/test/tap/shrinkwrap-empty-deps.js b/deps/npm/test/tap/shrinkwrap-empty-deps.js
index cf7e9a6e80..eeb5e656ef 100644
--- a/deps/npm/test/tap/shrinkwrap-empty-deps.js
+++ b/deps/npm/test/tap/shrinkwrap-empty-deps.js
@@ -1,19 +1,19 @@
-var fs = require('fs')
-var path = require('path')
+'use strict'
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
-var osenv = require('osenv')
-var rimraf = require('rimraf')
-var test = require('tap').test
+const common = require('../common-tap.js')
+const fs = require('fs')
+const mkdirp = require('mkdirp')
+const mr = require('npm-registry-mock')
+const osenv = require('osenv')
+const path = require('path')
+const rimraf = require('rimraf')
+const test = require('tap').test
-var common = require('../common-tap.js')
+const pkg = path.resolve(__dirname, 'shrinkwrap-empty-deps')
-var pkg = path.resolve(__dirname, 'shrinkwrap-empty-deps')
+const EXEC_OPTS = { cwd: pkg }
-var EXEC_OPTS = { cwd: pkg }
-
-var json = {
+const json = {
author: 'Rockbert',
name: 'shrinkwrap-empty-deps',
version: '0.0.0',
@@ -46,14 +46,11 @@ test('returns a list of removed items', function (t) {
t.ifError(err, 'shrinkwrap ran without issue')
t.notOk(code, 'shrinkwrap ran without raising error code')
- fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, desired) {
+ fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, found) {
t.ifError(err, 'read npm-shrinkwrap.json without issue')
t.same(
- {
- 'name': 'shrinkwrap-empty-deps',
- 'version': '0.0.0'
- },
- JSON.parse(desired),
+ JSON.parse(found).dependencies,
+ undefined,
'shrinkwrap handled empty deps without exploding'
)
diff --git a/deps/npm/test/tap/shrinkwrap-extra-metadata.js b/deps/npm/test/tap/shrinkwrap-extra-metadata.js
new file mode 100644
index 0000000000..c5f60e4c22
--- /dev/null
+++ b/deps/npm/test/tap/shrinkwrap-extra-metadata.js
@@ -0,0 +1,81 @@
+'use strict'
+
+const common = require('../common-tap.js')
+const fs = require('fs')
+const mkdirp = require('mkdirp')
+const mr = require('npm-registry-mock')
+const npm = require('../../lib/npm.js')
+const osenv = require('osenv')
+const path = require('path')
+const pkgSri = require('../../lib/utils/package-integrity.js')
+const rimraf = require('rimraf')
+const test = require('tap').test
+
+const pkg = path.join(__dirname, path.basename(__filename, '.js'))
+
+const EXEC_OPTS = {
+ cwd: pkg }
+
+const json = {
+ author: 'Rockbert',
+ name: 'shrinkwrap-extra-metadata',
+ version: '0.0.0'
+}
+
+test('setup', function (t) {
+ cleanup()
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(json, null, 2)
+ )
+
+ process.chdir(pkg)
+ t.end()
+})
+
+test('adds additional metadata fields from the pkglock spec', function (t) {
+ mr({ port: common.port }, function (er, s) {
+ common.npm(
+ [
+ '--registry', common.registry,
+ '--loglevel', 'silent',
+ 'shrinkwrap'
+ ],
+ { cwd: pkg, env: { NODE_PRESERVE_SYMLINKS: 'foo' } },
+ function (err, code, stdout, stderr) {
+ t.ifError(err, 'shrinkwrap ran without issue')
+ t.notOk(code, 'shrinkwrap ran without raising error code')
+
+ fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, desired) {
+ t.ifError(err, 'read npm-shrinkwrap.json without issue')
+ t.same(
+ {
+ 'name': 'shrinkwrap-extra-metadata',
+ 'version': '0.0.0',
+ 'lockfileVersion': npm.lockfileVersion,
+ 'packageIntegrity': pkgSri.hash(json),
+ 'preserveSymlinks': 'foo'
+ },
+ JSON.parse(desired),
+ 'shrinkwrap wrote the expected metadata fields'
+ )
+
+ s.close()
+ 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/shrinkwrap-lifecycle.js b/deps/npm/test/tap/shrinkwrap-lifecycle.js
index 0e84259667..8c0f36e3bb 100644
--- a/deps/npm/test/tap/shrinkwrap-lifecycle.js
+++ b/deps/npm/test/tap/shrinkwrap-lifecycle.js
@@ -22,22 +22,21 @@ test('npm shrinkwrap execution order', function (t) {
postshrinkwrap: 'echo this happens third'
}
}), 'utf8')
- common.npm(['shrinkwrap'], [], function (err, code, stdout) {
+ common.npm(['shrinkwrap', '--loglevel=error'], [], function (err, code, stdout, stderr) {
if (err) throw err
+ t.comment(stdout)
+ t.comment(stderr)
var indexOfFirst = stdout.indexOf('echo this happens first')
var indexOfSecond = stdout.indexOf('echo this happens second')
- var indexOfThird = stdout.indexOf('wrote npm-shrinkwrap.json')
- var indexOfFourth = stdout.indexOf('echo this happens third')
+ var indexOfThird = stdout.indexOf('echo this happens third')
t.ok(indexOfFirst >= 0)
t.ok(indexOfSecond >= 0)
t.ok(indexOfThird >= 0)
- t.ok(indexOfFourth >= 0)
t.ok(indexOfFirst < indexOfSecond)
t.ok(indexOfSecond < indexOfThird)
- t.ok(indexOfThird < indexOfFourth)
t.end()
})
diff --git a/deps/npm/test/tap/shrinkwrap-local-dependency.js b/deps/npm/test/tap/shrinkwrap-local-dependency.js
index d3537756c0..992343ccf5 100644
--- a/deps/npm/test/tap/shrinkwrap-local-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-local-dependency.js
@@ -16,14 +16,11 @@ var shrinkwrap = {
version: '1.0.0',
dependencies: {
mod2: {
- version: '1.0.0',
- from: path.join('mods', 'mod2'),
- resolved: 'file:' + path.join('mods', 'mod2'),
+ version: 'file:' + path.join('mods', 'mod2'),
dependencies: {
mod1: {
- version: '1.0.0',
- from: path.join('mods', 'mod1'),
- resolved: 'file:' + path.join('mods', 'mod1')
+ version: 'file:' + path.join('mods', 'mod1'),
+ bundled: true
}
}
}
@@ -88,7 +85,11 @@ test('shrinkwrap uses resolved with file: on local deps', function (t) {
t.comment(stderr.trim())
t.equal(code, 0, 'npm exited normally')
var data = fs.readFileSync(path.join(testdir, 'npm-shrinkwrap.json'), { encoding: 'utf8' })
- t.deepEqual(JSON.parse(data), shrinkwrap, 'shrinkwrap looks correct')
+ t.deepEqual(
+ JSON.parse(data).dependencies,
+ shrinkwrap.dependencies,
+ 'shrinkwrap looks correct'
+ )
t.end()
})
})
diff --git a/deps/npm/test/tap/shrinkwrap-nested.js b/deps/npm/test/tap/shrinkwrap-nested.js
index 92c81f29e3..d94e5ce222 100644
--- a/deps/npm/test/tap/shrinkwrap-nested.js
+++ b/deps/npm/test/tap/shrinkwrap-nested.js
@@ -1,5 +1,6 @@
'use strict'
var test = require('tap').test
+var Bluebird = require('bluebird')
var Tacks = require('tacks')
var File = Tacks.File
var Dir = Tacks.Dir
@@ -8,16 +9,16 @@ var path = require('path')
var common = require('../common-tap.js')
var testdir = path.resolve(__dirname, path.basename(__filename, '.js'))
-var modAdir = path.resolve(testdir, 'modA')
-var modB1dir = path.resolve(testdir, 'modB@1')
-var modB2dir = path.resolve(testdir, 'modB@2')
-var modCdir = path.resolve(testdir, 'modC')
+var modAtgz = path.resolve(testdir, 'modA') + '-1.0.0.tgz'
+var modB1tgz = path.resolve(testdir, 'modB') + '-1.0.0.tgz'
+var modB2tgz = path.resolve(testdir, 'modB') + '-2.0.0.tgz'
+var modCtgz = path.resolve(testdir, 'modC') + '-1.0.0.tgz'
var fixture = new Tacks(Dir({
'package.json': File({
dependencies: {
- modA: 'file://' + modAdir,
- modC: 'file://' + modCdir
+ modA: 'file://' + modAtgz,
+ modC: 'file://' + modCtgz
}
}),
'npm-shrinkwrap.json': File({
@@ -25,12 +26,12 @@ var fixture = new Tacks(Dir({
modA: {
version: '1.0.0',
from: 'modA',
- resolved: 'file://' + modAdir
+ resolved: 'file://' + modAtgz
},
modB: {
version: '1.0.0',
from: 'modB@1',
- resolved: 'file://' + modB1dir
+ resolved: 'file://' + modB1tgz
}
}
}),
@@ -39,7 +40,7 @@ var fixture = new Tacks(Dir({
name: 'modA',
version: '1.0.0',
dependencies: {
- 'modB': 'file://' + modB1dir
+ 'modB': 'file://' + modB1tgz
}
})
}),
@@ -62,7 +63,7 @@ var fixture = new Tacks(Dir({
name: 'modC',
version: '1.0.0',
dependencies: {
- 'modB': 'file://' + modB2dir
+ 'modB': 'file://' + modB2tgz
}
})
})
@@ -74,22 +75,22 @@ var newShrinkwrap = new Tacks(Dir({
modA: {
version: '1.0.0',
from: 'modA',
- resolved: 'file://' + modAdir
+ resolved: 'file://' + modAtgz
},
modB: {
version: '1.0.0',
from: 'modB@1',
- resolved: 'file://' + modB1dir
+ resolved: 'file://' + modB1tgz
},
modC: {
version: '1.0.0',
from: 'modC',
- resolved: 'file://' + modCdir,
+ resolved: 'file://' + modCtgz,
dependencies: {
modB: {
version: '1.0.0',
from: 'modB@1',
- resolved: 'file://' + modB1dir
+ resolved: 'file://' + modB1tgz
}
}
}
@@ -100,10 +101,10 @@ var newShrinkwrap = new Tacks(Dir({
'package.json': File({
_requested: {
name: 'modB',
- raw: 'modB@file:' + modB1dir,
- rawSpec: 'file:' + modB1dir,
+ raw: 'modB@file:' + modB1tgz,
+ rawSpec: 'file:' + modB1tgz,
scope: null,
- spec: modB1dir,
+ spec: modB1tgz,
type: 'directory'
},
dependencies: { },
@@ -128,9 +129,26 @@ function cleanup () {
test('setup', function (t) {
cleanup()
setup()
- common.npm(['install'], {cwd: testdir, stdio: [0, 2, 2]}, function (err, code) {
- if (err) throw err
- t.is(code, 0)
+ return Bluebird.try(() => {
+ return Bluebird.join(
+ common.npm(['pack', 'file:modB@1'], {cwd: testdir, stdio: [0, 2, 2]}),
+ common.npm(['pack', 'file:modB@2'], {cwd: testdir, stdio: [0, 2, 2]}),
+ function (b1, b2) {
+ t.is(b1[0], 0, 'pack modB@1')
+ t.is(b2[0], 0, 'pack modB@2')
+ })
+ }).then(() => {
+ return Bluebird.join(
+ common.npm(['pack', 'file:modA'], {cwd: testdir, stdio: [0, 2, 2]}),
+ common.npm(['pack', 'file:modC'], {cwd: testdir, stdio: [0, 2, 2]}),
+ function (a, c) {
+ t.is(a[0], 0, 'pack modA')
+ t.is(c[0], 0, 'pack modC')
+ })
+ }).then(() => {
+ return common.npm(['install'], {cwd: testdir, stdio: [0, 2, 2]})
+ }).spread((code) => {
+ t.is(code, 0, 'top level install')
t.end()
})
})
diff --git a/deps/npm/test/tap/shrinkwrap-optional-dependency.js b/deps/npm/test/tap/shrinkwrap-optional-dependency.js
index ee44b9a7b0..0373e89e62 100644
--- a/deps/npm/test/tap/shrinkwrap-optional-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-optional-dependency.js
@@ -43,7 +43,7 @@ test('shrinkwrap does not fail on missing optional dependency', function (t) {
npm.commands.shrinkwrap([], true, function (err, results) {
if (err) return fail(err)
- t.deepEqual(results, desired)
+ t.deepEqual(results.dependencies, desired.dependencies)
s.close()
t.end()
})
@@ -63,8 +63,8 @@ var desired = {
dependencies: {
'test-package': {
version: '0.0.0',
- from: 'test-package@0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz'
+ resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
+ integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
}
}
}
diff --git a/deps/npm/test/tap/shrinkwrap-optional-property.js b/deps/npm/test/tap/shrinkwrap-optional-property.js
index 47f11a750b..19e55a45f8 100644
--- a/deps/npm/test/tap/shrinkwrap-optional-property.js
+++ b/deps/npm/test/tap/shrinkwrap-optional-property.js
@@ -33,7 +33,7 @@ test('shrinkwrap adds optional property when optional dependency', function (t)
npm.commands.shrinkwrap([], true, function (err, results) {
if (err) return fail(err)
- t.deepEqual(results, desired)
+ t.deepEqual(results.dependencies, desired.dependencies)
s.close()
t.end()
})
@@ -53,14 +53,14 @@ var desired = {
dependencies: {
'test-package': {
version: '0.0.0',
- from: 'test-package@0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz'
+ resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
+ integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
},
'underscore': {
version: '1.3.3',
- from: 'underscore@1.3.3',
resolved: 'http://localhost:1337/underscore/-/underscore-1.3.3.tgz',
- optional: true
+ optional: true,
+ integrity: 'sha1-R6xTaD2vgyv6lS4XdEF9pHgXrkI='
}
}
}
diff --git a/deps/npm/test/tap/shrinkwrap-package-integrity.js b/deps/npm/test/tap/shrinkwrap-package-integrity.js
new file mode 100644
index 0000000000..6333757d7f
--- /dev/null
+++ b/deps/npm/test/tap/shrinkwrap-package-integrity.js
@@ -0,0 +1,50 @@
+'use strict'
+
+const pkgsri = require('../../lib/utils/package-integrity.js')
+const ssri = require('ssri')
+const test = require('tap').test
+
+test('generates integrity according to spec', (t) => {
+ const pkgJson = {
+ 'name': 'foo',
+ 'version': '1.0.0',
+ 'dependencies': {
+ 'x': '1.0.0'
+ },
+ 'devDependencies': {
+ 'y': '1.0.0'
+ },
+ 'optionalDependencies': {
+ 'z': '1.0.0'
+ }
+ }
+ const integrity = pkgsri.hash(pkgJson)
+ t.ok(integrity && integrity.toString(), 'hash returned')
+ t.equal(
+ ssri.parse(integrity).toString(),
+ integrity,
+ 'hash is a valid ssri string'
+ )
+ t.ok(pkgsri.check(pkgJson, integrity), 'same-data integrity check succeeds')
+ t.done()
+})
+
+test('updates if anything changes in package.json', (t) => {
+ const pkgJson = {
+ 'name': 'foo',
+ 'version': '1.0.0',
+ 'dependencies': {
+ 'x': '1.0.0'
+ },
+ 'devDependencies': {
+ 'y': '1.0.0'
+ },
+ 'optionalDependencies': {
+ 'z': '1.0.0'
+ }
+ }
+ const sri = pkgsri.hash(pkgJson)
+ pkgJson.version = '1.2.3'
+ t.equal(pkgsri.check(pkgJson, sri), false, 'no match after pkgJson change')
+ t.done()
+})
diff --git a/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js b/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js
index d3e86fcd65..6cc388946e 100644
--- a/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js
+++ b/deps/npm/test/tap/shrinkwrap-prod-dependency-also.js
@@ -46,7 +46,11 @@ test("shrinkwrap --also=development doesn't strip out prod dependencies", functi
t.ifError(ex, 'read shrinkwrap')
}
}
- t.deepEqual(results, desired, 'results have dev dep')
+ t.deepEqual(
+ results.dependencies,
+ desired.dependencies,
+ 'results have dev dep'
+ )
s.done()
t.end()
})
@@ -66,14 +70,14 @@ var desired = {
dependencies: {
request: {
version: '0.9.0',
- from: 'request@0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz'
+ resolved: common.registry + '/request/-/request-0.9.0.tgz',
+ integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
},
underscore: {
dev: true,
version: '1.5.1',
- from: 'underscore@1.5.1',
- resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz'
+ resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz',
+ integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck='
}
}
}
diff --git a/deps/npm/test/tap/shrinkwrap-prod-dependency.js b/deps/npm/test/tap/shrinkwrap-prod-dependency.js
index 57d6ecd3b1..023a3bf0b7 100644
--- a/deps/npm/test/tap/shrinkwrap-prod-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-prod-dependency.js
@@ -26,7 +26,7 @@ test("shrinkwrap --dev doesn't strip out prod dependencies", function (t) {
npm.commands.shrinkwrap([], true, function (err, results) {
if (err) return t.fail(err)
- t.deepEqual(results, desired)
+ t.deepEqual(results.dependencies, desired.dependencies)
s.close()
t.end()
})
@@ -46,14 +46,14 @@ var desired = {
dependencies: {
request: {
version: '0.9.0',
- from: 'request@0.9.0',
- resolved: common.registry + '/request/-/request-0.9.0.tgz'
+ resolved: common.registry + '/request/-/request-0.9.0.tgz',
+ integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4='
},
underscore: {
dev: true,
version: '1.5.1',
- from: 'underscore@1.5.1',
- resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz'
+ resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz',
+ integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck='
}
}
}
diff --git a/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js b/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js
index eacea9e3ce..507f2c56f8 100644
--- a/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js
+++ b/deps/npm/test/tap/shrinkwrap-save-dev-with-existing-deps.js
@@ -53,12 +53,16 @@ var example_shrinkwrap_json = {
var installed_prod_pkg_json = {
_id: 'installed-prod@1.0.0',
+ _integrity: 'sha1-deadbeef',
+ _resolved: 'foo',
name: 'installed-prod',
version: '1.0.0'
}
var installed_dev_pkg_json = {
_id: 'installed-dev@1.0.0',
+ _integrity: 'sha1-deadbeef',
+ _resolved: 'foo',
name: 'installed-dev',
version: '1.0.0'
}
diff --git a/deps/npm/test/tap/shrinkwrap-save-dev-without-existing-dev-deps.js b/deps/npm/test/tap/shrinkwrap-save-dev-without-existing-dev-deps.js
deleted file mode 100644
index 436b17895a..0000000000
--- a/deps/npm/test/tap/shrinkwrap-save-dev-without-existing-dev-deps.js
+++ /dev/null
@@ -1,87 +0,0 @@
-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 common = require('../common-tap.js')
-
-var base = path.resolve(__dirname, path.basename(__filename, '.js'))
-var installme = path.join(base, 'installme')
-var installme_pkg = path.join(installme, 'package.json')
-var example = path.join(base, 'example')
-var example_shrinkwrap = path.join(example, 'npm-shrinkwrap.json')
-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 }
-
-var installme_pkg_json = {
- name: 'installme',
- version: '1.0.0',
- dependencies: {}
-}
-
-var example_pkg_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {
- 'installed': '1.0'
- },
- devDependencies: {}
-}
-
-var example_shrinkwrap_json = {
- name: 'example',
- version: '1.0.0',
- dependencies: {
- installed: {
- version: '1.0.0'
- }
- }
-}
-
-var installed_pkg_json = {
- _id: 'installed@1.0.0',
- name: 'installed',
- version: '1.0.0'
-}
-
-function writeJson (filename, obj) {
- mkdirp.sync(path.dirname(filename))
- fs.writeFileSync(filename, JSON.stringify(obj, null, 2))
-}
-
-test('setup', function (t) {
- cleanup()
- writeJson(installme_pkg, installme_pkg_json)
- writeJson(example_pkg, example_pkg_json)
- writeJson(example_shrinkwrap, example_shrinkwrap_json)
- writeJson(installed_pkg, installed_pkg_json)
- t.end()
-})
-
-test('install --save-dev leaves dev deps alone', function (t) {
- common.npm(['install', '--save-dev', 'file://' + installme], EXEC_OPTS, function (er, code, stdout, stderr) {
- t.ifError(er, "spawn didn't catch fire")
- t.is(code, 0, 'install completed ok')
- t.is(stderr, '', 'install completed without error output')
- var shrinkwrap = JSON.parse(fs.readFileSync(example_shrinkwrap))
- t.ok(shrinkwrap.dependencies.installed, "save-dev new install didn't remove dep")
- t.notOk(shrinkwrap.dependencies.installme, 'save-dev new install DID NOT add new dev dep')
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
-function cleanup () {
- process.chdir(osenv.tmpdir())
- rimraf.sync(base)
-}
diff --git a/deps/npm/test/tap/shrinkwrap-scoped-auth.js b/deps/npm/test/tap/shrinkwrap-scoped-auth.js
index a469bc8356..6d5130137e 100644
--- a/deps/npm/test/tap/shrinkwrap-scoped-auth.js
+++ b/deps/npm/test/tap/shrinkwrap-scoped-auth.js
@@ -53,20 +53,12 @@ test('authed npm install with shrinkwrapped scoped package', function (t) {
t.equal(code, 0, 'npm install exited OK')
try {
var results = JSON.parse(stdout)
+ t.match(results, {added: [{name: '@scoped/underscore', version: '1.3.1'}]}, '@scoped/underscore installed')
} catch (ex) {
console.error('#', ex)
t.ifError(ex, 'stdout was valid JSON')
}
- if (results) {
- var installedversion = {
- 'version': '1.3.1',
- 'from': '>=1.3.1 <2',
- 'resolved': 'http://localhost:1337/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
- }
- t.isDeeply(results.dependencies['@scoped/underscore'], installedversion, '@scoped/underscore installed')
- }
-
t.end()
}
)
diff --git a/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js b/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js
index 0011f7b6f1..71e6371bcf 100644
--- a/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js
+++ b/deps/npm/test/tap/shrinkwrap-shared-dev-dependency.js
@@ -3,89 +3,87 @@ var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
-var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
-var npm = npm = require('../../')
-var pkg = path.resolve(__dirname, 'shrinkwrap-shared-dev-dependency')
+var pkg = path.resolve(__dirname, path.basename(__filename, '.js'))
-test("shrinkwrap doesn't strip out the shared dependency", function (t) {
- t.plan(1)
-
- mr({ port: common.port }, function (er, s) {
- setup(function (err) {
- if (err) return t.fail(err)
-
- npm.install('.', function (err) {
- if (err) return t.fail(err)
- npm.config.set('dev', true) // npm install unsets this
+var opts = {
+ env: common.newEnv().extend({
+ npm_config_cache: path.resolve(pkg, 'cache'),
+ npm_config_registry: common.registry
+ }),
+ stdio: [0, 1, 2],
+ cwd: pkg
+}
- npm.commands.shrinkwrap([], true, function (err, results) {
- if (err) return t.fail(err)
+var json = {
+ author: 'Domenic Denicola',
+ name: 'npm-test-shrinkwrap-shared-dev-dependency',
+ version: '0.0.0',
+ dependencies: {
+ 'test-package-with-one-dep': '0.0.0'
+ },
+ devDependencies: {
+ 'test-package': '0.0.0'
+ }
+}
- t.deepEqual(results, desired)
- s.close()
- t.end()
- })
- })
- })
+var server
+test('setup', function (t) {
+ setup()
+ mr({ port: common.port }, function (er, s) {
+ if (er) throw er
+ server = s
+ t.done()
})
})
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
-
var desired = {
name: 'npm-test-shrinkwrap-shared-dev-dependency',
version: '0.0.0',
dependencies: {
'test-package-with-one-dep': {
version: '0.0.0',
- from: 'test-package-with-one-dep@0.0.0',
- resolved: common.registry +
- '/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz'
+ resolved: common.registry + '/test-package-with-one-dep/-/test-package-with-one-dep-0.0.0.tgz',
+ integrity: 'sha1-JWwVltusKyPRImjatagCuy42Wsg='
},
'test-package': {
version: '0.0.0',
- from: 'test-package@0.0.0',
- resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz'
+ resolved: common.registry + '/test-package/-/test-package-0.0.0.tgz',
+ integrity: 'sha1-sNMrbEXCWcV4uiADdisgUTG9+9E='
}
}
}
-var json = {
- author: 'Domenic Denicola',
- name: 'npm-test-shrinkwrap-shared-dev-dependency',
- version: '0.0.0',
- dependencies: {
- 'test-package-with-one-dep': '0.0.0'
- },
- devDependencies: {
- 'test-package': '0.0.0'
- }
-}
+test("shrinkwrap doesn't strip out the shared dependency", function (t) {
+ t.plan(3)
+
+ return common.npm(['install'], opts).spread((code) => {
+ t.is(code, 0, 'install')
+ return common.npm(['shrinkwrap'], opts)
+ }).spread((code) => {
+ t.is(code, 0, 'shrinkwrap')
+ var results = JSON.parse(fs.readFileSync(`${pkg}/npm-shrinkwrap.json`))
+ t.deepEqual(results.dependencies, desired.dependencies)
+ t.end()
+ })
+})
-function setup (cb) {
+test('cleanup', function (t) {
+ server.close()
+ cleanup()
+ t.end()
+})
+
+function setup () {
cleanup()
mkdirp.sync(pkg)
fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2))
- process.chdir(pkg)
-
- var opts = {
- cache: path.resolve(pkg, 'cache'),
- registry: common.registry,
- // important to make sure devDependencies don't get stripped
- dev: true
- }
- npm.load(opts, cb)
}
function cleanup () {
- process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
diff --git a/deps/npm/test/tap/shrinkwrap-transitive-dev.js b/deps/npm/test/tap/shrinkwrap-transitive-dev.js
deleted file mode 100644
index 7a8f5b45d2..0000000000
--- a/deps/npm/test/tap/shrinkwrap-transitive-dev.js
+++ /dev/null
@@ -1,83 +0,0 @@
-'use strict'
-var fs = require('fs')
-var path = require('path')
-var test = require('tap').test
-var Tacks = require('tacks')
-var common = require('../common-tap.js')
-var File = Tacks.File
-var Dir = Tacks.Dir
-
-var testname = path.basename(__filename, '.js')
-var testdir = path.join(__dirname, testname)
-var cachedir = path.join(testdir, 'cache')
-var swfile = path.join(testdir, 'npm-shrinkwrap.json')
-var fixture = new Tacks(
- Dir({
- cache: Dir(),
- mods: Dir({
- moda: Dir({
- 'package.json': File({
- name: 'moda',
- version: '1.0.0',
- dependencies: {
- modb: '../modb'
- }
- })
- }),
- modb: Dir({
- 'package.json': File({
- name: 'modb',
- version: '1.0.0'
- })
- })
- }),
- 'package.json': File({
- name: testname,
- version: '1.0.0',
- devDependencies: {
- moda: 'file:mods/moda'
- }
- })
- })
-)
-
-function setup () {
- cleanup()
- fixture.create(testdir)
-}
-
-function cleanup () {
- fixture.remove(testdir)
-}
-
-test('setup', function (t) {
- setup()
- common.npm(['install', '--cache=' + cachedir], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'setup ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- t.end()
- })
-})
-
-test('transitive-deps-of-dev-deps', function (t) {
- common.npm(['shrinkwrap', '--loglevel=error', '--only=prod'], {cwd: testdir}, function (err, code, stdout, stderr) {
- if (err) throw err
- t.is(code, 0, 'shrinkwrap ran ok')
- t.comment(stdout.trim())
- t.comment(stderr.trim())
- try {
- var shrinkwrap = JSON.parse(fs.readFileSync(swfile))
- t.isDeeply(shrinkwrap.dependencies, {}, 'empty shrinkwrap')
- } catch (ex) {
- t.ifError(ex)
- }
- t.end()
- })
-})
-
-test('cleanup', function (t) {
- cleanup()
- t.end()
-})
diff --git a/deps/npm/test/tap/spawn-enoent.js b/deps/npm/test/tap/spawn-enoent.js
index 320e477e0e..c81460fdcf 100644
--- a/deps/npm/test/tap/spawn-enoent.js
+++ b/deps/npm/test/tap/spawn-enoent.js
@@ -28,7 +28,7 @@ test('enoent script', function (t) {
'npm_config_loglevel': 'warn'
}
}, function (er, code, sout, serr) {
- t.similar(serr, /npm ERR! Failed at the x@1\.2\.3 start script 'wharble-garble-blorst'\./)
+ t.similar(serr, /npm ERR! Failed at the x@1\.2\.3 start script\./)
t.end()
})
})
diff --git a/deps/npm/test/tap/spec-local-specifiers.js b/deps/npm/test/tap/spec-local-specifiers.js
new file mode 100644
index 0000000000..b9a484a11b
--- /dev/null
+++ b/deps/npm/test/tap/spec-local-specifiers.js
@@ -0,0 +1,630 @@
+'use strict'
+var path = require('path')
+var test = require('tap').test
+var fs = require('fs')
+var rimraf = require('rimraf')
+var mr = require('npm-registry-mock')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Symlink = Tacks.Symlink
+var Dir = Tacks.Dir
+var common = require('../common-tap.js')
+var isWindows = require('../../lib/utils/is-windows.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: common.emptyEnv().extend({
+ npm_config_cache: cachedir,
+ npm_config_tmp: tmpdir,
+ npm_config_prefix: globaldir,
+ npm_config_registry: common.registry,
+ npm_config_loglevel: 'error'
+ }),
+ stdio: [0, 'pipe', 2]
+}
+var confE = {
+ cwd: testdir,
+ env: conf.env,
+ stdio: [0, 'pipe', 'pipe']
+}
+
+function readJson (file) {
+ return JSON.parse(fs.readFileSync(file))
+}
+
+function isSymlink (t, file, message) {
+ try {
+ var info = fs.lstatSync(file)
+ t.is(info.isSymbolicLink(), true, message)
+ } catch (ex) {
+ if (ex.code === 'ENOENT') {
+ t.fail(message, {found: null, wanted: 'symlink', compare: 'fs.lstat(' + file + ')'})
+ } else {
+ t.fail(message, {found: ex, wanted: 'symlink', compare: 'fs.lstat(' + file + ')'})
+ }
+ }
+}
+
+function fileExists (t, file, message) {
+ try {
+ fs.statSync(file)
+ t.pass(message)
+ } catch (ex) {
+ if (ex.code === 'ENOENT') {
+ t.fail(message, {found: null, wanted: 'exists', compare: 'fs.stat(' + file + ')'})
+ } else {
+ t.fail(message, {found: ex, wanted: 'exists', compare: 'fs.stat(' + file + ')'})
+ }
+ }
+}
+
+function noFileExists (t, file, message) {
+ try {
+ fs.statSync(file)
+ t.fail(message, {found: 'exists', wanted: 'not exists', compare: 'fs.stat(' + file + ')'})
+ } catch (ex) {
+ if (ex.code === 'ENOENT') {
+ t.pass(message)
+ } else {
+ t.fail(message, {found: ex, wanted: 'not exists', compare: 'fs.stat(' + file + ')'})
+ }
+ }
+}
+
+var server
+var testdirContent = {
+ node_modules: Dir({}),
+ pkga: Dir({
+ 'package.json': File({
+ name: 'pkga',
+ version: '1.0.0'
+ })
+ }),
+ pkgb: Dir({
+ 'package.json': File({
+ name: 'pkgb',
+ version: '1.0.0'
+ })
+ }),
+ pkgc: Dir({
+ 'package.json': File({
+ name: 'pkgc',
+ version: '1.0.0'
+ })
+ }),
+ pkgd: Dir({
+ 'package.json': File({
+ name: 'pkgd',
+ version: '1.0.0'
+ })
+ })
+}
+
+var fixture
+function setup () {
+ fixture = new Tacks(Dir({
+ cache: Dir(),
+ global: Dir(),
+ tmp: Dir(),
+ testdir: Dir(testdirContent)
+ }))
+ cleanup()
+ fixture.create(basedir)
+}
+
+function cleanup () {
+ fixture.remove(basedir)
+}
+
+test('setup', function (t) {
+ process.nextTick(function () {
+ setup()
+ mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
+ if (err) throw err
+ server = s
+ t.done()
+ })
+ })
+})
+
+var installOk = []
+var slashes = [ 'unix', 'win' ]
+slashes.forEach(function (os) {
+ var slash = os === 'unix'
+ ? function (ss) { return ss.replace(/\\/g, '/') }
+ : function (ss) { return ss.replace(/\//g, '\\') }
+ installOk.push(os + '-file-abs-f')
+ testdirContent[os + '-file-abs-f'] = Dir({
+ 'package.json': File({
+ name: os + '-file-abs-f',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file:' + slash(testdir + '/pkga')
+ }
+ })
+ })
+ installOk.push(os + '-file-abs-fff')
+ testdirContent[os + '-file-abs-fff'] = Dir({
+ 'package.json': File({
+ name: os + '-file-abs-fff',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file://' + slash(testdir + '/pkga')
+ }
+ })
+ })
+ installOk.push(os + '-file-rel')
+ testdirContent[os + '-file-rel'] = Dir({
+ 'package.json': File({
+ name: os + '-file-rel',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file:' + slash('../pkga')
+ }
+ })
+ })
+ installOk.push(os + '-file-rel-fffff')
+ testdirContent[os + '-file-rel-fffff'] = Dir({
+ 'package.json': File({
+ name: os + '-file-rel-fffff',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file:' + slash('/////../pkga')
+ }
+ })
+ })
+})
+
+testdirContent['win-abs-drive-win'] = Dir({
+ 'package.json': File({
+ name: 'win-abs-drive-win',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file:D:\\thing\\pkga'
+ }
+ })
+})
+
+testdirContent['win-abs-drive-unix'] = Dir({
+ 'package.json': File({
+ name: 'win-abs-drive-unix',
+ version: '1.0.0',
+ dependencies: {
+ pkga: 'file://D:/thing/pkga'
+ }
+ })
+})
+
+test('specifiers', function (t) {
+ t.plan(installOk.length + 2)
+ installOk.forEach(function (mod) {
+ t.test(mod, function (t) {
+ common.npm(['install', '--dry-run', '--json', 'file:' + mod], conf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ t.comment(stdout.trim())
+ t.done()
+ })
+ })
+ })
+ slashes.forEach(function (os) {
+ t.test('win-abs-drive-' + os, function (t) {
+ common.npm(['install', '--dry-run', '--json', 'file:win-abs-drive-' + os], confE, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.not(code, 0, 'command errored ok')
+ t.comment(stderr.trim())
+ if (isWindows) {
+ t.test('verify failure of file-not-found or wrong drive letter on windows')
+ } else {
+ var result = JSON.parse(stdout)
+ t.is(result.error && result.error.code, 'EWINDOWSPATH', 'verify failure due to windows paths not supported on non-Windows')
+ }
+
+ t.done()
+ })
+ })
+ })
+})
+testdirContent['mkdirp'] = Dir({
+ 'package.json': File({
+ name: 'mkdirp',
+ version: '9.9.9'
+ })
+})
+testdirContent['example'] = Dir({
+ 'minimist': Dir({
+ 'package.json': File({
+ name: 'minimist',
+ version: '9.9.9'
+ })
+ })
+})
+testdirContent['wordwrap'] = Dir({
+})
+testdirContent['prefer-pkg'] = Dir({
+ 'package.json': File({
+ name: 'perfer-pkg',
+ version: '1.0.0',
+ dependencies: {
+ 'mkdirp': 'latest'
+ }
+ }),
+ 'latest': Dir({
+ 'package.json': File({
+ name: 'mkdirp',
+ version: '9.9.9'
+ })
+ })
+})
+
+test('ambiguity', function (t) {
+ t.plan(5)
+ t.test('arg: looks like package name, is dir', function (t) {
+ common.npm(['install', 'mkdirp', '--dry-run', '--json'], conf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ const result = JSON.parse(stdout.trim())
+ t.like(result, {added: [{name: 'mkdirp', version: '9.9.9'}]}, 'got local dir')
+ t.done()
+ })
+ })
+ t.test('arg: looks like package name, is package', function (t) {
+ common.npm(['install', 'wordwrap', '--dry-run', '--json'], conf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ const result = JSON.parse(stdout.trim())
+ t.like(result, {added: [{name: 'wordwrap', version: '0.0.2'}]}, 'even with local dir w/o package.json, got global')
+ t.done()
+ })
+ })
+ t.test('arg: looks like github repo, is dir', function (t) {
+ common.npm(['install', 'example/minimist', '--dry-run', '--json'], conf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ const result = JSON.parse(stdout.trim())
+ t.like(result, {added: [{name: 'minimist', version: '9.9.9'}]}, 'got local dir')
+ t.done()
+ })
+ })
+ t.test('package: looks like tag, has dir, use tag', function (t) {
+ common.npm(['install', '--dry-run', '--json'], {cwd: path.join(testdir, 'prefer-pkg'), env: conf.env}, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ const result = JSON.parse(stdout.trim())
+ t.like(result, {added: [{name: 'mkdirp', version: '0.3.5'}]}, 'got local dir')
+ t.done()
+ })
+ })
+
+ t.test('test ambiguity for github repos')
+})
+testdirContent['existing-matches'] = Dir({
+ 'package.json': File({
+ name: 'existing-matches',
+ version: '1.0.0',
+ dependencies: {
+ 'pkga': 'file:../pkga',
+ 'pkgb': 'file:' + testdir + '/pkgb',
+ 'pkgc': 'file:../pkgc',
+ 'pkgd': 'file:' + testdir + '/pkgd'
+ }
+ }),
+ 'node_modules': Dir({
+ 'pkga': Symlink('../../pkga'),
+ 'pkgd': Symlink('../../pkgd')
+ })
+})
+
+test('existing install matches', function (t) {
+ t.plan(1)
+ // have to make these by hand because tacks doesn't support absolute paths in symlinks
+ fs.symlinkSync(testdir + '/pkgb', testdir + '/existing-matches/node_modules/pkgb', 'junction')
+ fs.symlinkSync(testdir + '/pkgc', testdir + '/existing-matches/node_modules/pkgc', 'junction')
+ t.test('relative symlink counts as match of relative symlink in package.json', function (t) {
+ common.npm(['ls', '--json'], {cwd: path.join(testdir, 'existing-matches'), env: conf.env}, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stdout) t.comment(stdout.trim())
+ t.test('specifically test that output is valid')
+ // relative symlink counts as match of relative symlink in package.json (pkga)
+ // relative symlink counts as match of abs symlink in package.json (pkgc)
+ // abs symlink counts as match of relative symlink in package.json (pkgb)
+ // abs symlink counts as match of abs symlink in package.json (pkgd)
+ t.done()
+ })
+ })
+})
+var ibdir = testdir + '/install-behavior'
+testdirContent['ib-out'] = Dir({
+ 'package.json': File({
+ name: 'ib-out',
+ version: '1.0.0',
+ dependencies: {
+ 'minimist': '*'
+ }
+ })
+})
+
+testdirContent['install-behavior'] = Dir({
+ 'package.json': File({
+ name: 'install-behavior',
+ version: '1.0.0'
+ }),
+ 'ib-in': Dir({
+ 'package.json': File({
+ name: 'ib-in',
+ version: '1.0.0',
+ dependencies: {
+ 'mkdirp': '*'
+ }
+ })
+ }),
+ 'noext': File(new Buffer(
+ '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
+ '06066626260a20dadccc144c1b1841f86000923334363037343536343732' +
+ '633000728c0c80f2d4760836505a5c925804740aa5e640bca200a78708a8' +
+ '56ca4bcc4d55b252cacb4fad2851d251502a4b2d2acecccf030a19ea19e8' +
+ '1928d5720db41b47c1281805a36014501f00005012007200080000',
+ 'hex'
+ )),
+ 'tarball-1.0.0.tgz': File(new Buffer(
+ '1f8b08000000000000032b484cce4e4c4fd52f80d07a59c5f9790c540606' +
+ '06066626260a20dadccc144c1b1841f8606062a6c060686c606e686a6c68' +
+ '666ec26000e480e5a9ed106ca0b4b824b108e8144acd817845014e0f1150' +
+ 'ad9497989baa64a5040c85a4c49c1c251d05a5b2d4a2e2ccfc3ca0a0a19e' +
+ '819e81522dd740bb72148c8251300a4601b50100473dd15800080000',
+ 'hex'
+ )),
+ 'not-module': Dir({}),
+ 'test-preinstall': Dir({
+ 'preinstall.js': File('console.log("CWD:" + process.cwd())'),
+ 'package.json': File({
+ name: 'test-preinstall',
+ version: '1.0.0',
+ scripts: {
+ 'preinstall': 'node ' + ibdir + '/test-preinstall/preinstall.js'
+ }
+ })
+ })
+})
+
+test('install behavior', function (t) {
+ var ibconf = {cwd: ibdir, env: conf.env.extend({npm_config_loglevel: 'silent'}), stdio: conf.stdio}
+ t.plan(7)
+ t.test('transitive deps for in-larger-module cases', function (t) {
+ common.npm(['install', 'file:ib-in'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stdout) t.comment(stdout.trim())
+ fileExists(t, ibdir + '/node_modules/mkdirp', 'transitive dep flattened')
+ isSymlink(t, ibdir + '/node_modules/ib-in', 'dep is symlink')
+ noFileExists(t, ibdir + '/ib-in/node_modules/mkdirp', 'transitive dep not nested')
+ t.done()
+ })
+ })
+ t.test('transitive deps for out-of-larger module cases', function (t) {
+ common.npm(['install', 'file:../ib-out'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stdout) t.comment(stdout.trim())
+ noFileExists(t, ibdir + '/node_modules/minimist', 'transitive dep not flattened')
+ fileExists(t, testdir + '/ib-out/node_modules/minimist', 'transitive dep nested')
+ t.done()
+ })
+ })
+ t.test('transitive deps for out-of-larger module cases w/ --preserve-symlinks', function (t) {
+ rimraf.sync(ibdir + '/node_modules')
+ rimraf.sync(testdir + '/ib-out/node_modules')
+ var env = conf.env.extend({NODE_PRESERVE_SYMLINKS: '1'})
+ common.npm(['install', 'file:../ib-out'], {cwd: ibdir, env: env}, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stdout) t.comment(stdout.trim())
+ fileExists(t, ibdir + '/node_modules/minimist', 'transitive dep flattened')
+ noFileExists(t, testdir + '/ib-out/node_modules/minimist', 'transitive dep not nested')
+ t.done()
+ })
+ })
+ t.test('tar/tgz/tar.gz should install a tarball', function (t) {
+ common.npm(['install', 'file:tarball-1.0.0.tgz'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ if (stdout) t.comment(stdout.trim())
+ fileExists(t, ibdir + '/node_modules/tarball')
+ t.done()
+ })
+ })
+ t.test('non tar/tgz/tar.gz files should give good error message', function (t) {
+ common.npm(['install', 'file:noext', '--json'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.not(code, 0, 'do not install files w/o extensions')
+ noFileExists(t, ibdir + '/node_modules/noext')
+ var result = JSON.parse(stdout)
+ t.like(result, {error: {code: 'ENOLOCAL'}}, 'new type of error')
+ t.done()
+ })
+ })
+ t.test('directories without package.json should give good error message', function (t) {
+ common.npm(['install', 'file:not-module', '--json'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.not(code, 0, 'error on dir w/o module')
+ var result = JSON.parse(stdout)
+ t.like(result, {error: {code: 'ENOLOCAL'}}, 'new type of error')
+ t.done()
+ })
+ })
+ t.test('verify preinstall step runs after finalize, such that cwd is as expected', function (t) {
+ common.npm(['install', 'file:test-preinstall'], ibconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ isSymlink(t, `${ibdir}/node_modules/test-preinstall`, 'installed as symlink')
+ t.notLike(stdout, /CWD:.*[.]staging/, 'cwd should not be in staging')
+
+ t.test('verify that env is as expected')
+ t.done()
+ })
+ })
+})
+var sbdir = testdir + '/save-behavior'
+testdirContent['save-behavior'] = Dir({
+ 'package.json': File({
+ name: 'save-behavior',
+ version: '1.0.0'
+ }),
+ 'npm-shrinkwrap.json': File({
+ name: 'save-behavior',
+ version: '1.0.0',
+ dependencies: {}
+ }),
+ 'transitive': Dir({
+ 'package.json': File({
+ name: 'transitive',
+ version: '1.0.0',
+ dependencies: {
+ 'pkgc': 'file:../../pkgc'
+ }
+ })
+ })
+})
+testdirContent['sb-transitive'] = Dir({
+ 'package.json': File({
+ name: 'sb-transitive',
+ version: '1.0.0',
+ dependencies: {
+ 'sbta': 'file:sbta'
+ }
+ }),
+ 'sbta': Dir({
+ 'package.json': File({
+ name: 'sbta',
+ version: '1.0.0'
+ })
+ })
+})
+var sbdirp = testdir + '/save-behavior-pre'
+testdirContent['save-behavior-pre'] = Dir({
+ 'package.json': File({
+ name: 'save-behavior',
+ version: '1.0.0'
+ }),
+ 'npm-shrinkwrap.json': File({
+ name: 'save-behavior',
+ version: '1.0.0',
+ dependencies: {}
+ })
+})
+testdirContent['sb-transitive-preserve'] = Dir({
+ 'package.json': File({
+ name: 'sb-transitive-preserve',
+ version: '1.0.0',
+ dependencies: {
+ 'sbtb': 'file:sbtb'
+ }
+ }),
+ 'sbtb': Dir({
+ 'package.json': File({
+ name: 'sbtb',
+ version: '1.0.0'
+ })
+ })
+})
+test('save behavior', function (t) {
+ t.plan(6)
+ var sbconf = {cwd: sbdir, env: conf.env, stdio: conf.stdio}
+ t.test('to package.json and npm-shrinkwrap.json w/ abs', function (t) {
+ common.npm(['install', '--save', 'file:' + testdir + '/pkga'], sbconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ var pjson = readJson(sbdir + '/package.json')
+ var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
+ t.is(pjson.dependencies.pkga, 'file:../pkga', 'package.json')
+ var sdep = shrinkwrap.dependencies
+ t.like(sdep, {pkga: {version: 'file:../pkga', resolved: null}}, 'npm-shrinkwrap.json')
+ t.done()
+ })
+ })
+ t.test('to package.json and npm-shrinkwrap.json w/ drive abs')
+ t.test('to package.json and npm-shrinkwrap.json w/ rel', function (t) {
+ common.npm(['install', '--save', 'file:../pkgb'], sbconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ var pjson = readJson(sbdir + '/package.json')
+ var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
+ t.is(pjson.dependencies.pkgb, 'file:../pkgb', 'package.json')
+ var sdep = shrinkwrap.dependencies
+ t.like(sdep, {pkgb: {version: 'file:../pkgb', resolved: null}}, 'npm-shrinkwrap.json')
+ t.done()
+ })
+ })
+ t.test('internal transitive dependencies of shrinkwraps', function (t) {
+ common.npm(['install', '--save', 'file:transitive'], sbconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ var pjson = readJson(sbdir + '/package.json')
+ var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
+ t.is(pjson.dependencies.transitive, 'file:transitive', 'package.json')
+ var sdep = shrinkwrap.dependencies.transitive || {}
+ var tdep = shrinkwrap.dependencies.pkgc
+ t.is(sdep.version, 'file:transitive', 'npm-shrinkwrap.json direct dep')
+ t.is(tdep.version, 'file:../pkgc', 'npm-shrinkwrap.json transitive dep')
+ t.done()
+ })
+ })
+ t.test('external transitive dependencies of shrinkwraps', function (t) {
+ common.npm(['install', '--save', 'file:../sb-transitive'], sbconf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ var pjson = readJson(sbdir + '/package.json')
+ var shrinkwrap = readJson(sbdir + '/npm-shrinkwrap.json')
+ var deps = pjson.dependencies || {}
+ t.is(deps['sb-transitive'], 'file:../sb-transitive', 'package.json')
+ var sdep = shrinkwrap.dependencies['sb-transitive'] || {}
+ var tdep = sdep.dependencies.sbta
+ t.like(tdep, {bundled: true, version: 'file:../sb-transitive/sbta'}, 'npm-shrinkwrap.json transitive dep')
+ t.like(sdep, {bundled: null, version: 'file:../sb-transitive'}, 'npm-shrinkwrap.json direct dep')
+ t.done()
+ })
+ })
+ t.test('external transitive dependencies of shrinkwraps > preserve symlinks', function (t) {
+ var preserveEnv = conf.env.extend({NODE_PRESERVE_SYMLINKS: '1'})
+ var preserveConf = {cwd: sbdirp, env: preserveEnv, stdio: conf.stdio}
+ common.npm(['install', '--save', 'file:../sb-transitive-preserve'], preserveConf, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'command ran ok')
+ var pjson = readJson(sbdirp + '/package.json')
+ var shrinkwrap = readJson(sbdirp + '/npm-shrinkwrap.json')
+ t.is(pjson.dependencies['sb-transitive-preserve'], 'file:../sb-transitive-preserve', 'package.json')
+ var sdep = shrinkwrap.dependencies['sb-transitive-preserve'] || {}
+ var tdep = shrinkwrap.dependencies.sbtb
+ t.like(sdep, {bundled: null, version: 'file:../sb-transitive-preserve'}, 'npm-shrinkwrap.json direct dep')
+ t.like(tdep, {bundled: null, version: 'file:../sb-transitive-preserve/sbtb'}, 'npm-shrinkwrap.json transitive dep')
+ t.done()
+ })
+ })
+})
+
+test('removal', function (t) {
+ t.plan(3)
+ t.test('should remove the symlink')
+ t.test('should not remove the transitive deps if it was not a `link:` type specifier.')
+ t.test("should not remove transitive deps if it's outside the package and --preserver-symlinks isn't set")
+})
+
+test('misc', function (t) {
+ t.plan(3)
+ t.test('listing: should look right, not include version')
+ t.test('outdated: show LOCAL for wanted / latest')
+ t.test('update: if specifier exists, do nothing. otherwise as if `npm install`.')
+})
+
+test('cleanup', function (t) {
+ server.close()
+ cleanup()
+ t.done()
+})
diff --git a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js b/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js
index 73eeee81a6..cf5aac110b 100644
--- a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js
+++ b/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js
@@ -1,10 +1,17 @@
'use strict'
-var test = require('tap').test
-var npm = require('../../lib/npm')
-var stream = require('readable-stream')
-var moduleName = 'xyzzy-wibble'
-var testModule = {
+const common = require('../common-tap.js')
+const mr = require('npm-registry-mock')
+const npm = require('../../lib/npm')
+const osenv = require('osenv')
+const path = require('path')
+const rimraf = require('rimraf')
+const test = require('tap').test
+
+const testdir = path.join(__dirname, path.basename(__filename, '.js'))
+
+const moduleName = 'xyzzy-wibble'
+const testModule = {
name: moduleName,
'dist-tags': {
latest: '1.3.0-a',
@@ -46,43 +53,54 @@ var testModule = {
}
}
-var lastFetched
-test('setup', function (t) {
- npm.load(function () {
- npm.config.set('loglevel', 'silly')
- npm.registry = {
- get: function (uri, opts, cb) {
- setTimeout(function () {
- cb(null, testModule, null, {statusCode: 200})
- })
- },
- fetch: function (u, opts, cb) {
- lastFetched = u
- setTimeout(function () {
- var empty = new stream.Readable()
- empty.push(null)
- cb(null, empty)
- })
- }
- }
- t.end()
+let server
+test('setup', (t) => {
+ mr({port: common.port}, (er, s) => {
+ if (er) throw er
+ t.ok(true, 'mock registry loaded')
+ server = s
+ npm.load({
+ loglevel: 'silent',
+ registry: common.registry,
+ cache: path.join(testdir, 'cache')
+ }, (err) => {
+ if (err) { throw err }
+ t.ok(true, 'npm loaded')
+ t.end()
+ })
})
})
-test('splat', function (t) {
- t.plan(8)
- var addNamed = require('../../lib/cache/add-named.js')
- addNamed('xyzzy-wibble', '*', testModule, function (err, pkg) {
- t.error(err, 'Succesfully resolved a splat package')
- t.is(pkg.name, moduleName)
- t.is(pkg.version, testModule['dist-tags'].latest)
- t.is(lastFetched, 'https://registry.npmjs.org/aproba/-/xyzzy-wibble-1.3.0-a.tgz')
+test('splat', (t) => {
+ server.get('/xyzzy-wibble').reply(200, testModule)
+ return npm.commands.cache.add('xyzzy-wibble', '*', testdir).then((pkg) => {
+ throw new Error(`Was not supposed to succeed on ${pkg}`)
+ }).catch((err) => {
+ t.equal(err.code, 'E404', 'got a 404 on the tarball fetch')
+ t.equal(
+ err.uri,
+ testModule.versions['1.3.0-a'].dist.tarball,
+ 'tried to get tarball for `latest` tag'
+ )
npm.config.set('tag', 'other')
- addNamed('xyzzy-wibble', '*', testModule, function (err, pkg) {
- t.error(err, 'Succesfully resolved a splat package')
- t.is(pkg.name, moduleName)
- t.is(pkg.version, testModule['dist-tags'].other)
- t.is(lastFetched, 'https://registry.npmjs.org/aproba/-/xyzzy-wibble-1.2.0-a.tgz')
- })
+ return npm.commands.cache.add('xyzzy-wibble', '*', testdir)
+ }).then((pkg) => {
+ throw new Error(`Was not supposed to succeed on ${pkg}`)
+ }).catch((err) => {
+ t.equal(err.code, 'E404', 'got a 404 on the tarball fetch')
+ t.equal(
+ err.uri,
+ testModule.versions['1.2.0-a'].dist.tarball,
+ 'tried to get tarball for `other` tag'
+ )
+ server.close()
+ })
+})
+
+test('cleanup', (t) => {
+ process.chdir(osenv.tmpdir())
+ rimraf(testdir, () => {
+ t.ok(true, 'cleaned up test dir')
+ t.done()
})
})
diff --git a/deps/npm/test/tap/tagged-version-matching.js b/deps/npm/test/tap/tagged-version-matching.js
index f7d51d90b7..f5847c2657 100644
--- a/deps/npm/test/tap/tagged-version-matching.js
+++ b/deps/npm/test/tap/tagged-version-matching.js
@@ -4,6 +4,7 @@ var test = require('tap').test
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')
@@ -29,27 +30,18 @@ var fixture = new Tacks(Dir({
global: Dir(),
tmp: Dir(),
testdir: Dir({
+ example: Dir({
+ 'package.json': File({
+ dependencies: {
+ tagdep: 'latest',
+ gitdep: 'npm/example-gitdep'
+ },
+ name: 'example',
+ version: '1.0.0'
+ })
+ }),
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'
- })
- }),
+ example: Symlink('../example'),
gitdep: Dir({
'package.json': File({
_from: 'npm/example-gitdep',
@@ -145,13 +137,32 @@ test('tagged-version-matching', function (t) {
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')
+ var expected = {
+ name: 'tagged-version-matching',
+ version: '1.0.0',
+ dependencies: {
+ example: {
+ version: '1.0.0',
+ dependencies: {
+ gitdep: {
+ version: '1.0.0',
+ from: 'npm/example-gitdep'
+ },
+ tagdep: {
+ version: '1.0.0',
+ from: 'tagdep@latest'
+ }
+ }
+ },
+ gitdep: {
+ version: '1.0.0',
+ from: 'npm/example-gitdep'
+ }
+ }
+ }
+
+ t.like(result, expected, 'ls looks ok')
+ t.is((result.problems || []).length, 0, 'no problems')
t.done()
})
})
diff --git a/deps/npm/test/tap/tree-style.js b/deps/npm/test/tap/tree-style.js
index b2bf0ce709..12fdb0bbd9 100644
--- a/deps/npm/test/tap/tree-style.js
+++ b/deps/npm/test/tap/tree-style.js
@@ -1,4 +1,5 @@
'use strict'
+var Bluebird = require('bluebird')
var test = require('tap').test
var path = require('path')
var mkdirp = require('mkdirp')
@@ -18,7 +19,7 @@ var json = {
'name': 'test-tree-style',
'version': '1.0.0',
'dependencies': {
- 'modA': modA
+ 'modA': modA + '-1.0.0.tgz'
}
}
@@ -26,7 +27,7 @@ var modAJson = {
'name': 'modA',
'version': '1.0.0',
'dependencies': {
- 'modB': modB
+ 'modB': modB + '-1.0.0.tgz'
}
}
@@ -34,7 +35,7 @@ var modBJson = {
'name': 'modB',
'version': '1.0.0',
'dependencies': {
- 'modC': modC
+ 'modC': modC + '-1.0.0.tgz'
}
}
@@ -71,7 +72,17 @@ function cleanup () {
test('setup', function (t) {
setup()
- t.end()
+ return Bluebird.try(() => {
+ return common.npm(['pack', 'file:modC'], {cwd: base})
+ }).spread((code) => {
+ t.is(code, 0, 'pack modC')
+ return common.npm(['pack', 'file:modB'], {cwd: base})
+ }).spread((code) => {
+ t.is(code, 0, 'pack modB')
+ return common.npm(['pack', 'file:modA'], {cwd: base})
+ }).spread((code) => {
+ t.is(code, 0, 'pack modA')
+ })
})
function exists (t, filepath, msg) {
diff --git a/deps/npm/test/tap/uninstall-link-clean.js b/deps/npm/test/tap/uninstall-link-clean.js
index eccdac8b26..b4759e8895 100644
--- a/deps/npm/test/tap/uninstall-link-clean.js
+++ b/deps/npm/test/tap/uninstall-link-clean.js
@@ -14,7 +14,7 @@ var dep = path.join(__dirname, 'dep')
var work = path.join(__dirname, 'uninstall-link-clean-TEST')
var modules = path.join(work, 'node_modules')
-var EXEC_OPTS = { cwd: work }
+var EXEC_OPTS = { cwd: work, stdio: [0, 'ignore', 2] }
var world = 'console.log("hello blrbld")\n'
@@ -62,7 +62,7 @@ test('setup', function (t) {
test('installing package with links', function (t) {
common.npm(
[
- '--loglevel', 'silent',
+ '--loglevel', 'error',
'install', pkg
],
EXEC_OPTS,
@@ -86,7 +86,7 @@ test('installing package with links', function (t) {
test('uninstalling package with links', function (t) {
common.npm(
[
- '--loglevel', 'silent',
+ '--loglevel', 'error',
'uninstall', 'package'
],
EXEC_OPTS,
diff --git a/deps/npm/test/tap/uninstall-package.js b/deps/npm/test/tap/uninstall-package.js
index 549b403ccf..7cc7b1da1f 100644
--- a/deps/npm/test/tap/uninstall-package.js
+++ b/deps/npm/test/tap/uninstall-package.js
@@ -11,7 +11,7 @@ var common = require('../common-tap.js')
var pkg = path.join(__dirname, 'uninstall-package')
-var EXEC_OPTS = { cwd: pkg }
+var EXEC_OPTS = { cwd: pkg, stdio: [0, 'pipe', 2] }
var json = {
name: 'uninstall-package',
@@ -39,25 +39,26 @@ test('returns a list of removed items', function (t) {
common.npm(
[
'--registry', common.registry,
- '--loglevel', 'silent',
+ '--loglevel', 'error',
'install', '.'
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
- t.ifError(err, 'install ran without issue')
+ if (err) throw err
t.notOk(code, 'install ran without raising error code')
common.npm(
[
'--registry', common.registry,
- '--loglevel', 'silent',
+ '--loglevel', 'error',
+ '--parseable',
'uninstall', 'underscore', 'request', 'lala'
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
- t.ifError(err, 'uninstall ran without issue')
+ if (err) throw err
t.notOk(code, 'uninstall ran without raising error code')
- t.has(stdout, /- underscore@1.3.3/, 'underscore uninstalled')
- t.has(stdout, /- request@0.9.5/, 'request uninstalled')
+ t.has(stdout, /^remove\tunderscore\t1.3.3\t/m, 'underscore uninstalled')
+ t.has(stdout, /^remove\trequest\t0.9.5\t/m, 'request uninstalled')
s.close()
t.end()
diff --git a/deps/npm/test/tap/uninstall-save.js b/deps/npm/test/tap/uninstall-save.js
index c097659d22..47cffdb521 100644
--- a/deps/npm/test/tap/uninstall-save.js
+++ b/deps/npm/test/tap/uninstall-save.js
@@ -12,7 +12,7 @@ var server
var pkg = path.join(__dirname, 'uninstall-save')
-var EXEC_OPTS = { cwd: pkg }
+var EXEC_OPTS = { cwd: pkg, stdio: [0, 'ignore', 2] }
var json = {
name: 'uninstall-save',
@@ -32,7 +32,7 @@ test('uninstall --save removes rm-ed package from package.json', function (t) {
common.npm(
[
'--registry', common.registry,
- '--loglevel', 'silent',
+ '--loglevel', 'error',
'--save-prefix', '^',
'--save',
'install', 'underscore@latest'
diff --git a/deps/npm/test/tap/unit-deps-childDependencySpecifier.js b/deps/npm/test/tap/unit-deps-childDependencySpecifier.js
deleted file mode 100644
index 68f9ea6bea..0000000000
--- a/deps/npm/test/tap/unit-deps-childDependencySpecifier.js
+++ /dev/null
@@ -1,59 +0,0 @@
-'use strict'
-var test = require('tap').test
-var requireInject = require('require-inject')
-var asap = require('asap')
-
-// we're just mocking to avoid having to call `npm.load`
-var deps = requireInject('../../lib/install/deps.js', {
- '../../lib/npm.js': {
- config: {
- get: function () { return 'mock' }
- },
- limit: {
- fetch: 10
- }
- }
-})
-
-var childDependencySpecifier = deps._childDependencySpecifier
-
-test('childDependencySpecifier', function (t) {
- var tree = {
- resolved: {},
- package: {
- name: 'bar',
- _requested: ''
- }
- }
-
- childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
- t.deepEqual(tree.resolved, {
- foo: {
- '^1.0.0': {
- raw: 'foo@^1.0.0',
- escapedName: 'foo',
- scope: null,
- name: 'foo',
- rawSpec: '^1.0.0',
- spec: '>=1.0.0 <2.0.0',
- type: 'range'
- }
- }
- }, 'should populate resolved')
-
- var order = []
-
- childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
- order.push(1)
- childDependencySpecifier(tree, 'foo', '^1.0.0', function () {
- order.push(3)
- t.deepEqual(order, [1, 2, 3], 'should yield nested callbacks')
- t.end()
- })
- })
-
- asap(function () {
- order.push(2)
- })
- })
-})
diff --git a/deps/npm/test/tap/unit-deps-earliestInstallable.js b/deps/npm/test/tap/unit-deps-earliestInstallable.js
index 5b69d20142..538cfe6c09 100644
--- a/deps/npm/test/tap/unit-deps-earliestInstallable.js
+++ b/deps/npm/test/tap/unit-deps-earliestInstallable.js
@@ -1,6 +1,7 @@
'use strict'
var test = require('tap').test
var requireInject = require('require-inject')
+var npa = require('npm-package-arg')
// we're just mocking to avoid having to call `npm.load`
var deps = requireInject('../../lib/install/deps.js', {
@@ -22,7 +23,9 @@ test('earliestInstallable should consider devDependencies', function (t) {
package: {
name: 'dep1',
dependencies: { dep2: '2.0.0' }
- }
+ },
+ path: '/dep1',
+ realpath: '/dep1'
}
// a library required by the base package
@@ -30,7 +33,9 @@ test('earliestInstallable should consider devDependencies', function (t) {
package: {
name: 'dep2',
version: '1.0.0'
- }
+ },
+ path: '/dep2',
+ realpath: '/dep2'
}
// an incompatible verson of dep2. required by dep1
@@ -38,27 +43,23 @@ test('earliestInstallable should consider devDependencies', function (t) {
package: {
name: 'dep2',
version: '2.0.0',
- _from: {
- raw: 'dep2@1.0.0',
- scope: null,
- escapedName: 'dep2',
- name: 'dep2',
- rawSpec: '1.0.0',
- spec: '1.0.0',
- type: 'version'
- }
+ _requested: npa('dep2@2.0.0')
},
- parent: dep1
+ parent: dep1,
+ path: '/dep1/node_modules/dep2a',
+ realpath: '/dep1/node_modules/dep2a'
}
var pkg = {
isTop: true,
- children: [dep1],
+ children: [dep1, dep2],
package: {
name: 'pkg',
dependencies: { dep1: '1.0.0' },
devDependencies: { dep2: '1.0.0' }
- }
+ },
+ path: '/',
+ realpath: '/'
}
dep1.parent = pkg
@@ -76,23 +77,19 @@ test('earliestInstallable should reuse shared prod/dev deps when they are identi
package: {
name: 'dep1',
dependencies: { dep2: '1.0.0' }
- }
+ },
+ path: '/dep1',
+ realpath: '/dep1'
}
var dep2 = {
package: {
name: 'dep2',
version: '1.0.0',
- _from: {
- raw: 'dep2@^1.0.0',
- scope: null,
- escapedName: 'dep2',
- name: 'dep2',
- rawSpec: '^1.0.0',
- spec: '>=1.0.0 <2.0.0',
- type: 'range'
- }
- }
+ _requested: npa('dep2@^1.0.0')
+ },
+ path: '/dep2',
+ realpath: '/dep2'
}
var pkg = {
@@ -102,7 +99,9 @@ test('earliestInstallable should reuse shared prod/dev deps when they are identi
name: 'pkg',
dependencies: { dep1: '1.0.0' },
devDependencies: { dep2: '^1.0.0' }
- }
+ },
+ path: '/',
+ realpath: '/'
}
dep1.parent = pkg
diff --git a/deps/npm/test/tap/unpublish-config.js b/deps/npm/test/tap/unpublish-config.js
index 92a0c731fe..f5d391d8c2 100644
--- a/deps/npm/test/tap/unpublish-config.js
+++ b/deps/npm/test/tap/unpublish-config.js
@@ -51,7 +51,7 @@ test('cursory test of unpublishing with config', function (t) {
child = common.npm(
[
'--userconfig', fixturePath,
- '--loglevel', 'silent',
+ '--loglevel', 'error',
'--force',
'unpublish'
],
diff --git a/deps/npm/test/tap/url-dependencies.js b/deps/npm/test/tap/url-dependencies.js
index bc54da7110..66b3e1a63b 100644
--- a/deps/npm/test/tap/url-dependencies.js
+++ b/deps/npm/test/tap/url-dependencies.js
@@ -85,7 +85,7 @@ function setup () {
function tarballWasFetched (output) {
return output.indexOf(
- 'http fetch GET ' +
+ 'GET 200 ' +
common.registry +
'/underscore/-/underscore-1.3.1.tgz'
) > -1
diff --git a/deps/npm/test/tap/version-allow-same-version.js b/deps/npm/test/tap/version-allow-same-version.js
new file mode 100644
index 0000000000..66f568dec9
--- /dev/null
+++ b/deps/npm/test/tap/version-allow-same-version.js
@@ -0,0 +1,65 @@
+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 npm = require('../../')
+var pkg = path.resolve(__dirname, 'version-allow-same-version')
+var cache = path.resolve(pkg, 'cache')
+var npmrc = path.resolve(pkg, './.npmrc')
+var configContents = 'sign-git-tag=false\n'
+
+test('npm version <semver> with same version without --allow-same-version', function (t) {
+ setup()
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
+ author: 'Lucas Theisen',
+ name: 'version-allow-same-version',
+ version: '0.0.1',
+ description: 'Test for npm version without --allow-same-version'
+ }), 'utf8')
+ npm.load({cache: cache, 'allow-same-version': false, registry: common.registry}, function () {
+ var version = require('../../lib/version')
+ version(['0.0.1'], function (err) {
+ t.ok(err)
+ t.like(err.message, /Version not changed/)
+ t.end()
+ })
+ })
+})
+test('npm version <semver> with same version with --allow-same-version', function (t) {
+ setup()
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
+ author: 'Lucas Theisen',
+ name: 'version-allow-same-version',
+ version: '0.0.1',
+ description: 'Test for npm version without --allow-same-version'
+ }), 'utf8')
+ npm.load({cache: cache, 'allow-same-version': true, registry: common.registry}, function () {
+ var version = require('../../lib/version')
+ version(['0.0.1'],
+ function (err) { t.ok(!err) },
+ function () { 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 () {
+ mkdirp.sync(pkg)
+ mkdirp.sync(path.join(pkg, 'node_modules'))
+ mkdirp.sync(cache)
+ fs.writeFileSync(npmrc, configContents, 'ascii')
+ process.chdir(pkg)
+}
diff --git a/deps/npm/test/tap/version-from-git.js b/deps/npm/test/tap/version-from-git.js
index 6f2c794ce2..330b0604d8 100644
--- a/deps/npm/test/tap/version-from-git.js
+++ b/deps/npm/test/tap/version-from-git.js
@@ -142,7 +142,7 @@ test('npm version from-git with an existing version', function (t) {
}
function checkVersion (er) {
- t.equal(er.message, 'Version not changed')
+ t.like(er.message, /Version not changed/)
t.done()
}
})