summaryrefslogtreecommitdiff
path: root/deps/npm/test/tap
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2016-03-29 23:30:51 -0700
committerMyles Borins <mborins@us.ibm.com>2016-04-01 14:47:39 -0700
commit0928584444ac6edf1ead0b93c9d05b1124183702 (patch)
treef64c5646b8e2817009e7afe97c2670c73d38a7eb /deps/npm/test/tap
parent39de601e1c3eda92eb2e37eca4e6aa960f206f39 (diff)
downloadnode-new-0928584444ac6edf1ead0b93c9d05b1124183702.tar.gz
deps: upgrade npm to 3.8.3
PR-URL: https://github.com/npm/node/pull/6 Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'deps/npm/test/tap')
-rw-r--r--deps/npm/test/tap/bearer-token-check.js118
-rw-r--r--deps/npm/test/tap/config-credentials.js2
-rw-r--r--deps/npm/test/tap/config-list.js43
-rw-r--r--deps/npm/test/tap/files-and-ignores.js558
-rw-r--r--deps/npm/test/tap/install-cli-production-nosave.js69
-rw-r--r--deps/npm/test/tap/install-report-just-installed.js76
-rw-r--r--deps/npm/test/tap/legacy-array-bin.js80
-rw-r--r--deps/npm/test/tap/legacy-bundled-git.js103
-rw-r--r--deps/npm/test/tap/legacy-dir-bin.js79
-rw-r--r--deps/npm/test/tap/legacy-ignore-nested-nm.js64
-rw-r--r--deps/npm/test/tap/legacy-missing-bindir.js82
-rw-r--r--deps/npm/test/tap/legacy-no-auth-leak.js75
-rw-r--r--deps/npm/test/tap/legacy-npm-self-install.js107
-rw-r--r--deps/npm/test/tap/legacy-optional-deps.js79
-rw-r--r--deps/npm/test/tap/legacy-platform-all.js73
-rw-r--r--deps/npm/test/tap/legacy-platform.js64
-rw-r--r--deps/npm/test/tap/legacy-private.js58
-rw-r--r--deps/npm/test/tap/legacy-shrinkwrap.js132
-rw-r--r--deps/npm/test/tap/legacy-test-package.js76
-rw-r--r--deps/npm/test/tap/legacy-url-dep.js61
-rw-r--r--deps/npm/test/tap/lifecycle-signal.js28
-rw-r--r--deps/npm/test/tap/logout-scoped.js70
-rw-r--r--deps/npm/test/tap/ls-depth-cli.js44
-rw-r--r--deps/npm/test/tap/ls-production-and-dev.js26
-rw-r--r--deps/npm/test/tap/map-to-registry.js81
-rw-r--r--deps/npm/test/tap/progress-config.js24
-rw-r--r--deps/npm/test/tap/run-script.js67
-rw-r--r--deps/npm/test/tap/shrinkwrap-scoped-auth.js1
-rw-r--r--deps/npm/test/tap/update-symlink.js91
-rw-r--r--deps/npm/test/tap/view.js54
30 files changed, 2474 insertions, 11 deletions
diff --git a/deps/npm/test/tap/bearer-token-check.js b/deps/npm/test/tap/bearer-token-check.js
new file mode 100644
index 0000000000..8ddbec29a4
--- /dev/null
+++ b/deps/npm/test/tap/bearer-token-check.js
@@ -0,0 +1,118 @@
+var resolve = require('path').resolve
+var writeFileSync = require('graceful-fs').writeFileSync
+
+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 toNerfDart = require('../../lib/config/nerf-dart.js')
+
+var pkg = resolve(__dirname, 'install-bearer-check')
+var outfile = resolve(pkg, '_npmrc')
+var modules = resolve(pkg, 'node_modules')
+var tarballPath = '/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
+// needs to be a different hostname to verify tokens (not) being sent correctly
+var tarballURL = 'http://lvh.me:' + common.port + tarballPath
+var tarball = resolve(__dirname, '../fixtures/scoped-underscore-1.3.1.tgz')
+
+var server
+
+var EXEC_OPTS = { cwd: pkg }
+
+function mocks (server) {
+ var auth = 'Bearer 0xabad1dea'
+ server.get(tarballPath, { authorization: auth }).reply(403, {
+ error: 'token leakage',
+ reason: 'This token should not be sent.'
+ })
+ server.get(tarballPath).replyWithFile(200, tarball)
+}
+
+test('setup', function (t) {
+ mr({ port: common.port, plugin: mocks }, function (er, s) {
+ server = s
+ t.ok(s, 'set up mock registry')
+ setup()
+ t.end()
+ })
+})
+
+test('authed npm install with tarball not on registry', function (t) {
+ common.npm(
+ [
+ 'install',
+ '--loglevel', 'silent',
+ '--json',
+ '--fetch-retries', 0,
+ '--userconfig', outfile
+ ],
+ EXEC_OPTS,
+ function (err, code, stdout, stderr) {
+ t.ifError(err, 'test runner executed without error')
+ t.equal(code, 0, 'npm install exited OK')
+ t.notOk(stderr, 'no output on stderr')
+ try {
+ var results = JSON.parse(stdout)
+ } 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://lvh.me:1337/scoped-underscore/-/scoped-underscore-1.3.1.tgz'
+ }
+ t.isDeeply(results.dependencies['@scoped/underscore'], installedversion, '@scoped/underscore installed')
+ }
+
+ t.end()
+ }
+ )
+})
+
+test('cleanup', function (t) {
+ server.close()
+ cleanup()
+ t.end()
+})
+
+var contents = '@scoped:registry=' + common.registry + '\n' +
+ toNerfDart(common.registry) + ':_authToken=0xabad1dea\n'
+
+var json = {
+ name: 'test-package-install',
+ version: '1.0.0'
+}
+
+var shrinkwrap = {
+ name: 'test-package-install',
+ version: '1.0.0',
+ dependencies: {
+ '@scoped/underscore': {
+ resolved: tarballURL,
+ from: '>=1.3.1 <2',
+ version: '1.3.1'
+ }
+ }
+}
+
+function setup () {
+ cleanup()
+ mkdirp.sync(modules)
+ writeFileSync(resolve(pkg, 'package.json'), JSON.stringify(json, null, 2) + '\n')
+ writeFileSync(outfile, contents)
+ writeFileSync(
+ resolve(pkg, 'npm-shrinkwrap.json'),
+ JSON.stringify(shrinkwrap, null, 2) + '\n'
+ )
+}
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+}
diff --git a/deps/npm/test/tap/config-credentials.js b/deps/npm/test/tap/config-credentials.js
index c1b981d0a5..f6f00ee0e6 100644
--- a/deps/npm/test/tap/config-credentials.js
+++ b/deps/npm/test/tap/config-credentials.js
@@ -79,7 +79,7 @@ test('set with token', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
}
t.same(conf.getCredentialsByURI(URI), expected, 'got bearer token and scope')
diff --git a/deps/npm/test/tap/config-list.js b/deps/npm/test/tap/config-list.js
new file mode 100644
index 0000000000..1c42b64c2e
--- /dev/null
+++ b/deps/npm/test/tap/config-list.js
@@ -0,0 +1,43 @@
+var fs = require('fs')
+var path = require('path')
+var test = require('tap').test
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var common = require('../common-tap.js')
+
+var pkg = path.resolve(__dirname, 'config-list')
+var opts = { cwd: pkg }
+var npmrc = path.resolve(pkg, '.npmrc')
+
+test('setup', function (t) {
+ rimraf.sync(pkg)
+ mkdirp.sync(pkg)
+ t.end()
+})
+
+test('config list includes project config', function (t) {
+ // Write per-project conf file
+ fs.writeFileSync(npmrc, 'foo=1234', 'utf8')
+
+ // Create empty package.json to indicate project root
+ fs.writeFileSync(path.resolve(pkg, 'package.json'), '{}', 'utf8')
+
+ common.npm(
+ ['config', 'list'],
+ opts,
+ function (err, code, stdout, stderr) {
+ t.ifError(err)
+ t.equal(stderr, '', 'stderr is empty')
+ var expected = '; project config ' + npmrc + '\nfoo = "1234"'
+ t.match(stdout, expected, 'contains project config')
+ t.end()
+ }
+ )
+})
+
+// TODO: test cases for other configuration types (cli, env, user, global)
+
+test('clean', function (t) {
+ rimraf.sync(pkg)
+ t.end()
+})
diff --git a/deps/npm/test/tap/files-and-ignores.js b/deps/npm/test/tap/files-and-ignores.js
new file mode 100644
index 0000000000..02371cfe3e
--- /dev/null
+++ b/deps/npm/test/tap/files-and-ignores.js
@@ -0,0 +1,558 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var fs = require('graceful-fs')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-files')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-files')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+test('basic file inclusion', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ 'include',
+ 'sub/include'
+ ]
+ }),
+ include: File(''),
+ sub: Dir({ include: File('') }),
+ notincluded: File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('include'), 'toplevel file included')
+ t.ok(fileExists('sub/include'), 'nested file included')
+ t.notOk(fileExists('notincluded'), 'unspecified file not included')
+ done()
+ })
+})
+
+test('basic file exclusion', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.npmignore': File(
+ 'ignore\n' +
+ 'sub/ignore\n'
+ ),
+ include: File(''),
+ ignore: File(''),
+ sub: Dir({ ignore: File('') })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('ignore'), 'toplevel file excluded')
+ t.notOk(fileExists('sub/ignore'), 'nested file excluded')
+ t.ok(fileExists('include'), 'unignored file included')
+ done()
+ })
+})
+
+test('toplevel-only and blanket ignores', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.npmignore': File(
+ './shallow1\n' +
+ '/shallow2\n' +
+ '/sub/onelevel\n' +
+ 'deep\n' +
+ ''
+ ),
+ shallow1: File(''),
+ shallow2: File(''),
+ deep: File(''),
+ sub: Dir({
+ shallow1: File(''),
+ shallow2: File(''),
+ onelevel: File(''),
+ deep: File(''),
+ sub: Dir({
+ deep: File(''),
+ onelevel: File('')
+ })
+ })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('shallow2'), '/ file excluded')
+ t.ok(fileExists('sub/shallow1'), 'nested ./ file included')
+ t.ok(fileExists('sub/shallow2'), 'nested / file included')
+ t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')
+ t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')
+ t.notOk(fileExists('deep'), 'deep file excluded')
+ t.notOk(fileExists('sub/deep'), 'nested deep file excluded')
+ t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')
+ t.ok(fileExists('shallow1'), './ file included')
+ done()
+ })
+})
+
+test('.npmignore works for nested directories recursively', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.npmignore': File(
+ '/ignore\n' +
+ 'deep\n'
+ ),
+ include: File(''),
+ ignore: File(''),
+ deep: File(''),
+ sub: Dir({
+ ignore: File(''),
+ include: File(''),
+ deep: File(''),
+ sub: Dir({
+ '.npmignore': File(
+ '/ignore\n'
+ ),
+ ignore: File(''),
+ include: File(''),
+ deep: File('')
+ })
+ })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('ignore'), 'toplevel file excluded')
+ t.ok(fileExists('include'), 'unignored file included')
+ t.ok(fileExists('sub/ignore'), 'same-name file in nested dir included')
+ t.ok(fileExists('sub/include'), 'unignored nested dir file included')
+ t.notOk(fileExists('sub/sub/ignore'), 'sub-sub-directory file excluded')
+ t.ok(fileExists('sub/sub/include'), 'sub-sube-directory file included')
+ t.notOk(fileExists('deep'), 'deep file excluded')
+ t.notOk(fileExists('sub/deep'), 'sub-dir deep file excluded')
+ t.notOk(fileExists('sub/sub/deep'), 'sub-sub-dir deep file excluded')
+ done()
+ })
+})
+
+test('.gitignore should have identical semantics', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.gitignore': File(
+ './shallow1\n' +
+ '/shallow2\n' +
+ '/sub/onelevel\n' +
+ 'deep\n' +
+ ''
+ ),
+ shallow1: File(''),
+ shallow2: File(''),
+ deep: File(''),
+ sub: Dir({
+ shallow1: File(''),
+ shallow2: File(''),
+ onelevel: File(''),
+ deep: File(''),
+ sub: Dir({
+ deep: File(''),
+ onelevel: File('')
+ })
+ })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('shallow2'), '/ file excluded')
+ t.ok(fileExists('sub/shallow1'), 'nested ./ file included')
+ t.ok(fileExists('sub/shallow2'), 'nested / file included')
+ t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')
+ t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')
+ t.notOk(fileExists('deep'), 'deep file excluded')
+ t.notOk(fileExists('sub/deep'), 'nested deep file excluded')
+ t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')
+ t.ok(fileExists('shallow1'), './ file included')
+ done()
+ })
+})
+
+test('.npmignore should always be overridden by files array', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ 'include',
+ 'sub'
+ ]
+ }),
+ '.npmignore': File(
+ 'include\n' +
+ 'ignore\n' +
+ 'sub/included\n'
+ ),
+ include: File(''),
+ ignore: File(''),
+ sub: Dir({
+ include: File('')
+ })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('ignore'), 'toplevel file excluded')
+ t.ok(fileExists('include'), 'unignored file included')
+ t.ok(fileExists('sub/include'), 'nested file included')
+ done()
+ })
+})
+
+test('.gitignore supported for ignores', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.gitignore': File(
+ 'ignore\n' +
+ 'sub/ignore\n'
+ ),
+ include: File(''),
+ ignore: File(''),
+ sub: Dir({ ignore: File('') })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('ignore'), 'toplevel file excluded')
+ t.notOk(fileExists('sub/ignore'), 'nested file excluded')
+ t.ok(fileExists('include'), 'unignored file included')
+ done()
+ })
+})
+
+test('.npmignore completely overrides .gitignore', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.npmignore': File(
+ 'ignore\n' +
+ 'sub/ignore\n'
+ ),
+ '.gitignore': File(
+ 'include\n' +
+ 'sub/include\n' +
+ 'extra\n'
+ ),
+ include: File(''),
+ sub: Dir({ include: File('') }),
+ extra: File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('include'), 'gitignored toplevel file included')
+ t.ok(fileExists('extra'), 'gitignored extra toplevel file included')
+ t.ok(fileExists('sub/include'), 'gitignored nested file included')
+ t.notOk(fileExists('ignore'), 'toplevel file excluded')
+ t.notOk(fileExists('sub/ignore'), 'nested file excluded')
+ done()
+ })
+})
+
+test('files array overrides .npmignore', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ 'include',
+ 'sub/include'
+ ]
+ }),
+ '.npmignore': File(
+ 'include\n' +
+ 'sub/include\n'
+ ),
+ include: File(''),
+ sub: Dir({ include: File('') })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('include'), 'toplevel file included')
+ t.ok(fileExists('sub/include'), 'nested file included')
+ done()
+ })
+})
+
+test('includes files regardless of emptiness', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ 'full',
+ 'empty'
+ ]
+ }),
+ full: File('This file has contents~'),
+ empty: File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('full'), 'contentful file included')
+ t.ok(fileExists('empty'), 'empty file included')
+ done()
+ })
+})
+
+test('.npmignore itself gets included', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ '.npmignore'
+ ]
+ }),
+ '.npmignore': File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('.npmignore'), '.npmignore included')
+ done()
+ })
+})
+
+test('include default files when missing files spec', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ 'index.js': File(''),
+ foo: File(''),
+ node_modules: Dir({foo: Dir({bar: File('')})})
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('index.js'), 'index.js included')
+ t.ok(fileExists('foo'), 'foo included')
+ t.notOk(fileExists('node_modules'), 'node_modules not included')
+ done()
+ })
+})
+
+test('include main file', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ main: 'foo.js',
+ files: []
+ }),
+ 'index.js': File(''),
+ 'foo.js': File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('foo.js'), 'foo.js included because of main')
+ t.notOk(fileExists('index.js'), 'index.js not included')
+ done()
+ })
+})
+
+test('certain files ignored unconditionally', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ '.git',
+ '.svn',
+ 'CVS',
+ '.hg',
+ '.lock-wscript',
+ '.wafpickle-0',
+ '.wafpickle-5',
+ '.wafpickle-50',
+ 'build/config.gypi',
+ 'npm-debug.log',
+ '.npmrc',
+ '.foo.swp',
+ '.DS_Store',
+ '._ohno'
+ ]
+ }),
+ '.git': Dir({foo: File('')}),
+ '.svn': Dir({foo: File('')}),
+ 'CVS': Dir({foo: File('')}),
+ '.hg': Dir({foo: File('')}),
+ '.lock-wscript': File(''),
+ '.wafpickle-0': File(''),
+ '.wafpickle-5': File(''),
+ '.wafpickle-50': File(''),
+ 'build': Dir({'config.gypi': File('')}),
+ 'npm-debug.log': File(''),
+ '.npmrc': File(''),
+ '.foo.swp': File(''),
+ '.DS_Store': Dir({foo: File('')}),
+ '._ohno': File(''),
+ '._ohnoes': Dir({noes: File('')})
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.notOk(fileExists('.git'), '.git not included')
+ t.notOk(fileExists('.svn'), '.svn not included')
+ t.notOk(fileExists('CVS'), 'CVS not included')
+ t.notOk(fileExists('.hg'), '.hg not included')
+ t.notOk(fileExists('.lock-wscript'), '.lock-wscript not included')
+ t.notOk(fileExists('.wafpickle-0'), '.wafpickle-0 not included')
+ t.notOk(fileExists('.wafpickle-5'), '.wafpickle-5 not included')
+ t.notOk(fileExists('.wafpickle-50'), '.wafpickle-50 not included')
+ t.notOk(fileExists('build/config.gypi'), 'build/config.gypi not included')
+ t.notOk(fileExists('npm-debug.log'), 'npm-debug.log not included')
+ t.notOk(fileExists('.npmrc'), '.npmrc not included')
+ t.notOk(fileExists('.foo.swp'), '.foo.swp not included')
+ t.notOk(fileExists('.DS_Store'), '.DS_Store not included')
+ t.notOk(fileExists('._ohno'), '._ohno not included')
+ t.notOk(fileExists('._ohnoes'), '._ohnoes not included')
+ done()
+ })
+})
+
+test('certain files included unconditionally', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5'
+ }),
+ '.npmignore': File(
+ 'package.json',
+ 'README',
+ 'Readme',
+ 'readme.md',
+ 'readme.randomext',
+ 'changelog',
+ 'CHAngelog',
+ 'ChangeLOG.txt',
+ 'license',
+ 'licence',
+ 'LICENSE',
+ 'LICENCE'
+ ),
+ 'README': File(''),
+ 'Readme': File(''),
+ 'readme.md': File(''),
+ 'readme.randomext': File(''),
+ 'changelog': File(''),
+ 'CHAngelog': File(''),
+ 'ChangeLOG.txt': File(''),
+ 'license': File(''),
+ 'licence': File(''),
+ 'LICENSE': File(''),
+ 'LICENCE': File('')
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('package.json'), 'package.json included')
+ t.ok(fileExists('README'), 'README included')
+ t.ok(fileExists('Readme'), 'Readme included')
+ t.ok(fileExists('readme.md'), 'readme.md included')
+ t.ok(fileExists('readme.randomext'), 'readme.randomext included')
+ t.ok(fileExists('changelog'), 'changelog included')
+ t.ok(fileExists('CHAngelog'), 'CHAngelog included')
+ t.ok(fileExists('ChangeLOG.txt'), 'ChangeLOG.txt included')
+ t.ok(fileExists('license'), 'license included')
+ t.ok(fileExists('licence'), 'licence included')
+ t.ok(fileExists('LICENSE'), 'LICENSE included')
+ t.ok(fileExists('LICENCE'), 'LICENCE included')
+ done()
+ })
+})
+
+test('folder-based inclusion works', function (t) {
+ var fixture = new Tacks(
+ Dir({
+ 'package.json': File({
+ name: 'npm-test-files',
+ version: '1.2.5',
+ files: [
+ 'sub1/sub',
+ 'sub2'
+ ]
+ }),
+ sub1: Dir({
+ sub: Dir({
+ include1: File(''),
+ include2: File('')
+ }),
+ ignored: File('')
+ }),
+ sub2: Dir({
+ include1: File(''),
+ include2: File(''),
+ empty: Dir({})
+ })
+ })
+ )
+ withFixture(t, fixture, function (done) {
+ t.ok(fileExists('sub1/sub/include1'), 'nested dir included')
+ t.ok(fileExists('sub1/sub/include2'), 'nested dir included')
+ t.notOk(fileExists('sub1/ignored'), 'unspecified file not included')
+
+ t.ok(fileExists('sub2/include1'), 'dir contents included')
+ t.ok(fileExists('sub2/include2'), 'dir contents included')
+ t.notOk(fileExists('sub2/empty'), 'empty dir not included')
+
+ done()
+ })
+})
+
+function fileExists (file) {
+ try {
+ return !!fs.statSync(path.resolve(installedpath, file))
+ } catch (_) {
+ return false
+ }
+}
+
+function withFixture (t, fixture, tester) {
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code) {
+ if (err) throw err
+ t.is(code, 0, 'install went ok')
+ tester(removeAndDone)
+ }
+ function removeAndDone (err) {
+ if (err) throw err
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+ t.done()
+ }
+}
diff --git a/deps/npm/test/tap/install-cli-production-nosave.js b/deps/npm/test/tap/install-cli-production-nosave.js
new file mode 100644
index 0000000000..cf69ad3fae
--- /dev/null
+++ b/deps/npm/test/tap/install-cli-production-nosave.js
@@ -0,0 +1,69 @@
+var fs = require('fs')
+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 server
+
+var pkg = path.join(__dirname, 'install-cli-production-nosave')
+
+var EXEC_OPTS = { cwd: pkg }
+
+var PACKAGE_JSON1 = {
+ name: 'install-cli-production-nosave',
+ version: '0.0.1',
+ dependencies: {
+ }
+}
+
+test('setup', function (t) {
+ setup()
+ mr({ port: common.port }, function (er, s) {
+ t.ifError(er, 'started mock registry')
+ server = s
+ t.end()
+ })
+})
+
+test('install --production <module> without --save exits successfully', function (t) {
+ common.npm(
+ [
+ '--registry', common.registry,
+ '--loglevel', 'silent',
+ 'install', '--production', 'underscore'
+ ],
+ EXEC_OPTS,
+ function (err, code) {
+ t.ifError(err, 'npm install ran without issue')
+ t.notOk(code, 'npm install exited with code 0')
+ t.end()
+ }
+ )
+})
+
+test('cleanup', function (t) {
+ server.close()
+ cleanup()
+ t.end()
+})
+
+function cleanup () {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(pkg)
+}
+
+function setup () {
+ cleanup()
+ mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(PACKAGE_JSON1, null, 2)
+ )
+
+ process.chdir(pkg)
+}
diff --git a/deps/npm/test/tap/install-report-just-installed.js b/deps/npm/test/tap/install-report-just-installed.js
new file mode 100644
index 0000000000..fb3bc65dbd
--- /dev/null
+++ b/deps/npm/test/tap/install-report-just-installed.js
@@ -0,0 +1,76 @@
+'use strict'
+var path = require('path')
+var test = require('tap').test
+var Tacks = require('tacks')
+var Dir = Tacks.Dir
+var File = Tacks.File
+var common = require('../common-tap.js')
+
+var testdir = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixture = new Tacks(Dir({
+ node_modules: Dir({
+ a: Dir({
+ 'package.json': File({
+ name: 'a',
+ version: '1.0.0',
+ dependencies: {
+ b: '1.0.0'
+ }
+ }),
+ node_modules: Dir({
+ b: Dir({
+ 'package.json': File({
+ name: 'b',
+ version: '1.0.0'
+ })
+ })
+ })
+ })
+ }),
+ 'b-src': Dir({
+ 'package.json': File({
+ name: 'b',
+ version: '1.0.0'
+ })
+ })
+}))
+
+function setup () {
+ cleanup()
+ fixture.create(testdir)
+}
+
+function cleanup () {
+ fixture.remove(testdir)
+}
+
+test('setup', function (t) {
+ setup()
+ t.end()
+})
+
+test('install-report', function (t) {
+ common.npm(['install', '--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')
+ try {
+ var report = JSON.parse(stdout)
+ t.pass('stdout was json')
+ } catch (ex) {
+ t.fail('stdout was json')
+ console.error(ex)
+ 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.end()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
diff --git a/deps/npm/test/tap/legacy-array-bin.js b/deps/npm/test/tap/legacy-array-bin.js
new file mode 100644
index 0000000000..3e421ee23e
--- /dev/null
+++ b/deps/npm/test/tap/legacy-array-bin.js
@@ -0,0 +1,80 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-array-bin')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-array-bin')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+var fixture = new Tacks(
+ Dir({
+ bin: Dir({
+ 'array-bin': File(
+ '#!/usr/bin/env node\n' +
+ "console.log('test ran ok')\n"
+ )
+ }),
+ 'package.json': File({
+ name: 'npm-test-array-bin',
+ version: '1.2.5',
+ bin: [
+ 'bin/array-bin'
+ ],
+ scripts: {
+ test: 'node test.js'
+ }
+ }),
+ 'test.js': File(
+ "require('child_process').exec('array-bin', { env: process.env },\n" +
+ ' function (err, stdout, stderr) {\n' +
+ " if (err && err.code) throw new Error('exited badly with code = ' + err.code)\n" +
+ ' console.log(stdout)\n' +
+ ' console.error(stderr)\n' +
+ ' }\n' +
+ ')\n'
+ )
+ })
+)
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+test('array-bin', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'install went ok')
+ t.equal(stderr, '', 'no error output')
+ common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
+ }
+ function testCheckAndRemove (err, code, stdout, stderr) {
+ t.ifError(err, 'npm test on array bin')
+ t.equal(code, 0, 'exited OK')
+ t.equal(stderr.trim(), '', 'no error output')
+ t.match(stdout, /test ran ok/, 'child script ran properly')
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ }
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-bundled-git.js b/deps/npm/test/tap/legacy-bundled-git.js
new file mode 100644
index 0000000000..355f9467c1
--- /dev/null
+++ b/deps/npm/test/tap/legacy-bundled-git.js
@@ -0,0 +1,103 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-bundled-git')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-bundled-git')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var minimatchExpected = {
+ name: 'minimatch',
+ description: 'a glob matcher in javascript',
+ version: '0.2.1',
+ repository: {
+ type: 'git',
+ url: 'git://github.com/isaacs/minimatch.git'
+ },
+ main: 'minimatch.js',
+ scripts: {
+ test: 'tap test'
+ },
+ engines: {
+ node: '*'
+ },
+ dependencies: {
+ 'lru-cache': '~1.0.5'
+ },
+ devDependencies: {
+ tap: '~0.1.3'
+ },
+ licenses: [
+ {
+ type: 'MIT',
+ url: 'http://github.com/isaacs/minimatch/raw/master/LICENSE'
+ }
+ ]
+}
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-bundled-git',
+ scripts: {
+ test: 'node test.js'
+ },
+ version: '1.2.5',
+ dependencies: {
+ glob: 'git://github.com/isaacs/node-glob.git#npm-test'
+ },
+ bundledDependencies: [
+ 'glob'
+ ]
+ })
+ })
+)
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+test('bundled-git', function (t) {
+ common.npm(['install', '--global-style', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'install went ok')
+
+ var actual = require(path.resolve(installedpath, 'node_modules/glob/node_modules/minimatch/package.json'))
+ Object.keys(minimatchExpected).forEach(function (key) {
+ t.isDeeply(actual[key], minimatchExpected[key], key + ' set to the right value')
+ })
+
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ }
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-dir-bin.js b/deps/npm/test/tap/legacy-dir-bin.js
new file mode 100644
index 0000000000..e9e6bdfe13
--- /dev/null
+++ b/deps/npm/test/tap/legacy-dir-bin.js
@@ -0,0 +1,79 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-dir-bin')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-dir-bin')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+var fixture = new Tacks(
+ Dir({
+ bin: Dir({
+ 'dir-bin': File(
+ '#!/usr/bin/env node\n' +
+ "console.log('test ran ok')\n"
+ )
+ }),
+ 'package.json': File({
+ name: 'npm-test-dir-bin',
+ version: '1.2.5',
+ directories: {
+ bin: './bin'
+ },
+ scripts: {
+ test: 'node test.js'
+ }
+ }),
+ 'test.js': File(
+ "require('child_process').exec('dir-bin', { env: process.env },\n" +
+ ' function (err, stdout, stderr) {\n' +
+ " if (err && err.code) throw new Error('exited badly with code = ' + err.code)\n" +
+ ' console.log(stdout)\n' +
+ ' console.error(stderr)\n' +
+ ' }\n' +
+ ')\n'
+ )
+ })
+)
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+test('dir-bin', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'install went ok')
+ common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
+ }
+ function testCheckAndRemove (err, code, stdout, stderr) {
+ t.ifError(err, 'npm test on array bin')
+ t.equal(code, 0, 'exited OK')
+ t.equal(stderr.trim(), '', 'no error output')
+ t.match(stdout, /test ran ok/, 'child script ran properly')
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ }
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-ignore-nested-nm.js b/deps/npm/test/tap/legacy-ignore-nested-nm.js
new file mode 100644
index 0000000000..095c41efa1
--- /dev/null
+++ b/deps/npm/test/tap/legacy-ignore-nested-nm.js
@@ -0,0 +1,64 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-ignore-nested-nm')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-ignore-nested-nm')
+var fs = require('graceful-fs')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fileData = 'I WILL NOT BE IGNORED!\n'
+var fixture = new Tacks(
+ Dir({
+ lib: Dir({
+ node_modules: Dir({
+ foo: File(fileData)
+ })
+ }),
+ 'package.json': File({
+ name: 'npm-test-ignore-nested-nm',
+ version: '1.2.5'
+ })
+ })
+)
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+test('ignore-nested-nm', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'install went ok')
+ var foopath = path.resolve(installedpath, 'lib/node_modules/foo')
+ fs.readFile(foopath, function (err, data) {
+ t.ifError(err, 'file read successfully')
+ t.equal(data.toString(), fileData)
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ })
+ }
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-missing-bindir.js b/deps/npm/test/tap/legacy-missing-bindir.js
new file mode 100644
index 0000000000..a55703bebd
--- /dev/null
+++ b/deps/npm/test/tap/legacy-missing-bindir.js
@@ -0,0 +1,82 @@
+'use strict'
+var path = require('path')
+var fs = require('fs')
+var test = require('tap').test
+var common = require('../common-tap.js')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-missing-bindir')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-missing-bindir')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-missing-bindir',
+ version: '0.0.0',
+ directories: {
+ bin: './not-found'
+ }
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+function installedExists (filename) {
+ try {
+ fs.statSync(path.resolve(installedpath, filename))
+ return true
+ } catch (ex) {
+ console.log(ex)
+ return false
+ }
+}
+
+test('missing-bindir', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ if (stderr) console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'install went ok')
+ t.is(installedExists('README'), true, 'README')
+ t.is(installedExists('package.json'), true, 'package.json')
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ }
+
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-no-auth-leak.js b/deps/npm/test/tap/legacy-no-auth-leak.js
new file mode 100644
index 0000000000..f837239250
--- /dev/null
+++ b/deps/npm/test/tap/legacy-no-auth-leak.js
@@ -0,0 +1,75 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-no-auth-leak',
+ version: '0.0.0',
+ scripts: {
+ test: 'node test.js'
+ }
+ }),
+ '.npmrc': File(
+ 'auth=abc',
+ 'authCrypt=def',
+ 'password=xyz',
+ '//registry.npmjs.org/:_authToken=nopenope'
+ ),
+ 'test.js': File(
+ 'var authTokenKeys = Object.keys(process.env)\n' +
+ ' .filter(function (key) { return /authToken/.test(key) })\n' +
+ 'console.log(JSON.stringify({\n' +
+ ' password: process.env.npm_config__password || null,\n' +
+ ' auth: process.env.npm_config__auth || null,\n' +
+ ' authCrypt: process.env.npm_config__authCrypt || null ,\n' +
+ ' authToken: authTokenKeys && process.env[authTokenKeys[0]] || null\n' +
+ '}))'
+ )
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('no-auth-leak', function (t) {
+ common.npm(['test'], {cwd: basepath}, function (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'test ran ok')
+ if (stderr) console.log(stderr)
+ var matchResult = /^[^{]*(\{(?:.|\n)*\})[^}]*$/
+ t.like(stdout, matchResult, 'got results with a JSON chunk in them')
+ var stripped = stdout.replace(matchResult, '$1')
+ var result = JSON.parse(stripped)
+ t.is(result.password, null, 'password')
+ t.is(result.auth, null, 'auth')
+ t.is(result.authCrypt, null, 'authCrypt')
+ t.is(result.authToken, null, 'authToken')
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(basepath)
+}
+
+function cleanup () {
+ fixture.remove(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-npm-self-install.js b/deps/npm/test/tap/legacy-npm-self-install.js
new file mode 100644
index 0000000000..313c059493
--- /dev/null
+++ b/deps/npm/test/tap/legacy-npm-self-install.js
@@ -0,0 +1,107 @@
+'use strict'
+var test = require('tap').test
+var fs = require('graceful-fs')
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var npmpath = path.resolve(__dirname, '../..')
+var basepath = path.resolve(osenv.tmpdir(), path.basename(__filename, '.js'))
+var globalpath = path.resolve(basepath, 'global')
+var extend = Object.assign || require('util')._extend
+var isWin32 = process.platform === 'win32'
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+var tarball
+
+test('build-tarball', function (t) {
+ common.npm(['pack'], {cwd: npmpath, stdio: ['ignore', 'pipe', process.stderr]}, function (err, code, stdout) {
+ if (err) throw err
+ t.is(code, 0, 'pack went ok')
+ tarball = path.resolve(npmpath, stdout.trim().replace(/^(?:.|\n)*(?:^|\n)(.*?[.]tgz)$/, '$1'))
+ t.match(tarball, /[.]tgz$/, 'got a tarball')
+ t.done()
+ })
+})
+
+function exists () {
+ try {
+ fs.statSync(path.resolve.apply(null, arguments))
+ return true
+ } catch (ex) {
+ return false
+ }
+}
+
+test('npm-self-install', function (t) {
+ if (!tarball) return t.done()
+
+ var env = extend({}, process.env)
+ var pathsep = isWin32 ? ';' : ':'
+ env.npm_config_prefix = globalpath
+ env.npm_config_global = 'true'
+ env.npm_config_npat = 'false'
+ env.NODE_PATH = null
+ env.npm_config_user_agent = null
+ env.npm_config_color = 'always'
+ env.npm_config_progress = 'always'
+ var PATH = env.PATH.split(pathsep)
+ var binpath = isWin32 ? globalpath : path.join(globalpath, 'bin')
+ var cmdname = isWin32 ? 'npm.cmd' : 'npm'
+ PATH.unshift(binpath)
+ env.PATH = PATH.join(pathsep)
+
+ var opts = {cwd: basepath, env: env, stdio: ['ignore', 'ignore', process.stderr]}
+
+ common.npm(['install', '--ignore-scripts', tarball], opts, installCheckAndTest)
+ function installCheckAndTest (err, code) {
+ if (err) throw err
+ t.is(code, 0, 'install went ok')
+ t.is(exists(binpath, cmdname), true, 'binary was installed')
+ t.is(exists(globalpath, 'lib', 'node_modules', 'npm'), true, 'module path exists')
+ common.npm(['ls', '--json', '--depth=0'], {cwd: basepath, env: env}, lsCheckAndRemove)
+ }
+ function lsCheckAndRemove (err, code, stdout, stderr) {
+ t.ifError(err, 'npm test on array bin')
+ t.equal(code, 0, 'exited OK')
+ t.equal(stderr.trim(), '', 'no error output')
+ var installed = JSON.parse(stdout.trim())
+ t.is(Object.keys(installed.dependencies).length, 1, 'one thing installed')
+ t.is(path.resolve(globalpath, installed.dependencies.npm.from), tarball, 'and it was our npm tarball')
+ common.npm(['rm', 'npm'], {cwd: basepath, env: env, stdio: 'inherit'}, removeCheck)
+ }
+ function removeCheck (err, code) {
+ if (err) throw err
+ t.is(code, 0, 'remove went ok')
+ common.npm(['ls', '--json', '--depth=0'], {cwd: basepath, env: env}, andDone)
+ }
+ function andDone (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(code, 0, 'remove went ok')
+ t.equal(stderr.trim(), '', 'no error output')
+ var installed = JSON.parse(stdout.trim())
+ t.ok(!installed.dependencies || installed.dependencies.length === 0, 'nothing left')
+ t.is(exists(binpath, cmdname), false, 'binary was removed')
+ t.is(exists(globalpath, 'lib', 'node_modules', 'npm'), false, 'module was entirely removed')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ mkdirp.sync(globalpath)
+}
+
+function cleanup () {
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-optional-deps.js b/deps/npm/test/tap/legacy-optional-deps.js
new file mode 100644
index 0000000000..80ad7cc47e
--- /dev/null
+++ b/deps/npm/test/tap/legacy-optional-deps.js
@@ -0,0 +1,79 @@
+'use strict'
+var path = require('path')
+var fs = require('fs')
+var test = require('tap').test
+var common = require('../common-tap.js')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var mr = require('npm-registry-mock')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-optional-deps')
+var modulepath = path.resolve(basepath, 'node_modules')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-optional-deps',
+ version: '1.2.5',
+ optionalDependencies: {
+ 'npm-test-foobarzaaakakaka': 'http://example.com/',
+ async: '10.999.14234',
+ mkdirp: '0.3.5',
+ optimist: 'some invalid version 99 #! $$ x y z',
+ 'npm-test-failer': '*'
+ }
+ })
+ })
+)
+
+var server
+
+test('setup', function (t) {
+ setup()
+ mr({port: common.port}, function (err, s) {
+ if (err) throw err
+ server = s
+ t.done()
+ })
+})
+
+test('optional-deps', function (t) {
+ server.get('/npm-test-failer').reply(404, {error: 'nope'})
+
+ var opts = ['--registry=' + common.registry, '--timeout=100']
+ common.npm(opts.concat(['install', fixturepath]), {cwd: basepath}, installCheckAndTest)
+
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ if (stderr) console.error(stderr)
+ server.done()
+ t.is(code, 0, 'install went ok')
+ var dir = fs.readdirSync(modulepath).sort()
+ t.isDeeply(dir, ['mkdirp', 'npm-test-optional-deps'], 'only one optional dep should be there')
+ t.is(require(path.resolve(modulepath, 'mkdirp', 'package.json')).version, '0.3.5', 'mkdirp version right')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ server.close()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-platform-all.js b/deps/npm/test/tap/legacy-platform-all.js
new file mode 100644
index 0000000000..2bfb19a457
--- /dev/null
+++ b/deps/npm/test/tap/legacy-platform-all.js
@@ -0,0 +1,73 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-platform-all')
+var modulepath = path.resolve(basepath, 'node_modules')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-platform-all',
+ version: '9.9.9-9',
+ homepage: 'http://www.zombo.com/',
+ os: [
+ 'darwin',
+ 'linux',
+ 'win32',
+ 'solaris',
+ 'haiku',
+ 'sunos',
+ 'freebsd',
+ 'openbsd',
+ 'netbsd'
+ ],
+ cpu: [
+ 'arm',
+ 'mips',
+ 'ia32',
+ 'x64',
+ 'sparc'
+ ]
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('platform-all', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ t.is(stderr, '', 'no error messages')
+ t.is(code, 0, 'install went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-platform.js b/deps/npm/test/tap/legacy-platform.js
new file mode 100644
index 0000000000..4e94148b21
--- /dev/null
+++ b/deps/npm/test/tap/legacy-platform.js
@@ -0,0 +1,64 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-platform')
+var modulepath = path.resolve(basepath, 'node_modules')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-platform',
+ version: '9.9.9-9',
+ homepage: 'http://www.youtube.com/watch?v=dQw4w9WgXcQ',
+ os: [
+ '!this_is_not_a_real_os',
+ '!neither_is_this'
+ ],
+ cpu: [
+ '!this_is_not_a_real_cpu',
+ '!this_isnt_either'
+ ]
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('platform', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ t.is(code, 0, 'install went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-private.js b/deps/npm/test/tap/legacy-private.js
new file mode 100644
index 0000000000..5e7817bf6a
--- /dev/null
+++ b/deps/npm/test/tap/legacy-private.js
@@ -0,0 +1,58 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-private')
+var modulepath = path.resolve(basepath, 'node_modules')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-private',
+ version: '9.9.9-9',
+ homepage: 'http://www.youtube.com/watch?v=1MLry6Cn_D4',
+ private: 'true'
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('private', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'install went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-shrinkwrap.js b/deps/npm/test/tap/legacy-shrinkwrap.js
new file mode 100644
index 0000000000..6f53030377
--- /dev/null
+++ b/deps/npm/test/tap/legacy-shrinkwrap.js
@@ -0,0 +1,132 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'npm-shrinkwrap.json': File({
+ name: 'npm-test-shrinkwrap',
+ version: '0.0.0',
+ dependencies: {
+ glob: {
+ version: '3.1.5',
+ from: 'git://github.com/isaacs/node-glob.git#npm-test',
+ resolved: 'git://github.com/isaacs/node-glob.git#67bda227fd7a559cca5620307c7d30a6732a792f',
+ dependencies: {
+ 'graceful-fs': {
+ version: '1.1.5',
+ resolved: 'https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.1.5.tgz',
+ dependencies: {
+ 'fast-list': {
+ version: '1.0.2',
+ resolved: 'https://registry.npmjs.org/fast-list/-/fast-list-1.0.2.tgz'
+ }
+ }
+ },
+ inherits: {
+ version: '1.0.0',
+ resolved: 'https://registry.npmjs.org/inherits/-/inherits-1.0.0.tgz'
+ },
+ minimatch: {
+ version: '0.2.1',
+ dependencies: {
+ 'lru-cache': {
+ version: '1.0.5'
+ }
+ }
+ }
+ }
+ },
+ minimatch: {
+ version: '0.1.5',
+ resolved: 'https://registry.npmjs.org/minimatch/-/minimatch-0.1.5.tgz',
+ dependencies: {
+ 'lru-cache': {
+ version: '1.0.5',
+ resolved: 'https://registry.npmjs.org/lru-cache/-/lru-cache-1.0.5.tgz'
+ }
+ }
+ },
+ 'npm-test-single-file': {
+ version: '1.2.3',
+ resolved: 'https://gist.github.com/isaacs/1837112/raw/9ef57a59fc22aeb1d1ca346b68826dcb638b8416/index.js'
+ }
+ }
+ }),
+ 'package.json': File({
+ author: 'Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)',
+ name: 'npm-test-shrinkwrap',
+ version: '0.0.0',
+ dependencies: {
+ 'npm-test-single-file': 'https://gist.github.com/isaacs/1837112/raw/9ef57a59fc22aeb1d1ca346b68826dcb638b8416/index.js',
+ glob: 'git://github.com/isaacs/node-glob.git#npm-test',
+ minimatch: '~0.1.0'
+ },
+ scripts: {
+ test: 'node test.js'
+ }
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('shrinkwrap', function (t) {
+ common.npm(['install'], {cwd: basepath}, installCheckAndTest)
+
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ t.is(code, 0, 'install went ok')
+
+ common.npm(['ls', '--json'], {cwd: basepath}, verifyLsMatchesShrinkwrap)
+ }
+
+ function verifyLsMatchesShrinkwrap (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ t.is(code, 0, 'ls went ok')
+ var actual = JSON.parse(stdout)
+ var expected = require(path.resolve(basepath, 'npm-shrinkwrap.json'))
+ // from is expected to vary
+ t.isDeeply(rmFrom(actual), rmFrom(expected))
+ t.done()
+ }
+
+ function rmFrom (obj) {
+ for (var i in obj) {
+ if (i === 'from') {
+ delete obj[i]
+ } else if (i === 'dependencies') {
+ for (var j in obj[i]) {
+ rmFrom(obj[i][j])
+ }
+ }
+ }
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(basepath)
+}
+
+function cleanup () {
+ fixture.remove(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-test-package.js b/deps/npm/test/tap/legacy-test-package.js
new file mode 100644
index 0000000000..b0cbaa01a5
--- /dev/null
+++ b/deps/npm/test/tap/legacy-test-package.js
@@ -0,0 +1,76 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-test-package')
+var modulepath = path.resolve(basepath, 'node_modules')
+var installedpath = path.resolve(modulepath, 'npm-test-test-package')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-test-package',
+ author: 'Testy McMock',
+ version: '1.2.3-99-b',
+ description: "This is a test package used for debugging. It has some random data and that's all."
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('test-package', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'install went ok')
+ common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
+ }
+
+ function testCheckAndRemove (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'npm test w/o test is ok')
+ common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
+ }
+
+ function removeCheckAndDone (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'remove went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/legacy-url-dep.js b/deps/npm/test/tap/legacy-url-dep.js
new file mode 100644
index 0000000000..9807d6916a
--- /dev/null
+++ b/deps/npm/test/tap/legacy-url-dep.js
@@ -0,0 +1,61 @@
+'use strict'
+var test = require('tap').test
+var common = require('../common-tap.js')
+var path = require('path')
+var rimraf = require('rimraf')
+var mkdirp = require('mkdirp')
+var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
+var fixturepath = path.resolve(basepath, 'npm-test-url-dep')
+var modulepath = path.resolve(basepath, 'node_modules')
+var Tacks = require('tacks')
+var File = Tacks.File
+var Dir = Tacks.Dir
+
+var fixture = new Tacks(
+ Dir({
+ README: File(
+ 'just an npm test\n'
+ ),
+ 'package.json': File({
+ name: 'npm-test-url-dep',
+ version: '1.2.3',
+ dependencies: {
+ jsonify: 'https://github.com/substack/jsonify/tarball/master',
+ sax: 'isaacs/sax-js',
+ 'canonical-host': 'git://github.com/isaacs/canonical-host'
+ }
+ })
+ })
+)
+
+test('setup', function (t) {
+ setup()
+ t.done()
+})
+
+test('url-dep', function (t) {
+ common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
+ function installCheckAndTest (err, code, stdout, stderr) {
+ if (err) throw err
+ console.error(stderr)
+ console.log(stdout)
+ t.is(code, 0, 'install went ok')
+ t.done()
+ }
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.done()
+})
+
+function setup () {
+ cleanup()
+ fixture.create(fixturepath)
+ mkdirp.sync(modulepath)
+}
+
+function cleanup () {
+ fixture.remove(fixturepath)
+ rimraf.sync(basepath)
+}
diff --git a/deps/npm/test/tap/lifecycle-signal.js b/deps/npm/test/tap/lifecycle-signal.js
index e28caf72f8..4c41a9e98a 100644
--- a/deps/npm/test/tap/lifecycle-signal.js
+++ b/deps/npm/test/tap/lifecycle-signal.js
@@ -16,7 +16,8 @@ var json = {
name: 'lifecycle-signal',
version: '1.2.5',
scripts: {
- preinstall: 'node -e "process.kill(process.pid,\'SIGSEGV\')"'
+ preinstall: 'node -e "process.kill(process.pid,\'SIGSEGV\')"',
+ forever: 'node -e "console.error(process.pid);setInterval(function(){},1000)"'
}
}
@@ -46,6 +47,31 @@ test('lifecycle signal abort', function (t) {
})
})
+test('lifecycle propagate signal term to child', function (t) {
+ // windows does not use lifecycle signals, abort
+ if (process.platform === 'win32' || process.env.TRAVIS) return t.end()
+
+ var innerChildPid
+ var child = spawn(npm, ['run', 'forever'], {
+ cwd: pkg
+ })
+ child.stderr.on('data', function (data) {
+ innerChildPid = Number.parseInt(data.toString(), 10)
+ t.doesNotThrow(function () {
+ process.kill(innerChildPid, 0) // inner child should be running
+ })
+ child.kill() // send SIGTERM to npm
+ })
+ child.on('exit', function (code, signal) {
+ t.equal(code, null)
+ t.equal(signal, 'SIGTERM')
+ t.throws(function () {
+ process.kill(innerChildPid, 0) // SIGTERM should have reached inner child
+ })
+ t.end()
+ })
+})
+
test('cleanup', function (t) {
cleanup()
t.end()
diff --git a/deps/npm/test/tap/logout-scoped.js b/deps/npm/test/tap/logout-scoped.js
new file mode 100644
index 0000000000..1323a4d32e
--- /dev/null
+++ b/deps/npm/test/tap/logout-scoped.js
@@ -0,0 +1,70 @@
+var fs = require('fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var mr = require('npm-registry-mock')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap.js')
+
+var pkg = path.resolve(__dirname, 'logout')
+var outfile = path.join(pkg, '_npmrc')
+var opts = { cwd: pkg }
+
+var contents = function () {/*
+foo=boo
+@bar:registry=http://localhost:1337
+//localhost:1337/:_authToken=glarb
+*/}.toString().split('\n').slice(1, -1).join('\n')
+
+function mocks (server) {
+ server.delete('/-/user/token/glarb')
+ .reply(200, {})
+}
+
+test('setup', function (t) {
+ cleanup()
+ setup()
+ t.end()
+})
+
+test('npm logout', function (t) {
+ mr({ port: common.port, plugin: mocks }, function (err, s) {
+ if (err) throw err
+
+ common.npm(
+ [
+ 'logout',
+ '--registry', common.registry,
+ '--scope', '@bar',
+ '--loglevel', 'silent',
+ '--userconfig', outfile
+ ],
+ opts,
+ function (err, code) {
+ t.ifError(err, 'no error output')
+ t.notOk(code, 'exited OK')
+
+ var config = fs.readFileSync(outfile, 'utf8')
+ t.equal(config, 'foo=boo\n', 'creds gone')
+ s.close()
+ t.end()
+ }
+ )
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})
+
+function setup () {
+ mkdirp.sync(pkg)
+ fs.writeFileSync(outfile, contents)
+}
+
+function cleanup () {
+ rimraf.sync(pkg)
+}
diff --git a/deps/npm/test/tap/ls-depth-cli.js b/deps/npm/test/tap/ls-depth-cli.js
index 760681427c..87eafced2c 100644
--- a/deps/npm/test/tap/ls-depth-cli.js
+++ b/deps/npm/test/tap/ls-depth-cli.js
@@ -159,6 +159,50 @@ test('npm ls --depth=Infinity --json', function (t) {
)
})
+test('npm ls --depth=0 --parseable --long', function (t) {
+ common.npm(
+ ['ls', '--depth=0', '--parseable', '--long'],
+ 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'
+ )
+ t.doesNotHave(
+ out,
+ /.*test-package@0\.0\.0/,
+ 'output not contains test-package'
+ )
+ t.end()
+ }
+ )
+})
+
+test('npm ls --depth=1 --parseable --long', function (t) {
+ common.npm(
+ ['ls', '--depth=1', '--parseable', '--long'],
+ 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'
+ )
+ t.has(
+ out,
+ /.*test-package@0\.0\.0/,
+ 'output not contains test-package'
+ )
+ t.end()
+ }
+ )
+})
+
test('cleanup', function (t) {
cleanup()
t.end()
diff --git a/deps/npm/test/tap/ls-production-and-dev.js b/deps/npm/test/tap/ls-production-and-dev.js
index e9bae3de79..80d67ea5e5 100644
--- a/deps/npm/test/tap/ls-production-and-dev.js
+++ b/deps/npm/test/tap/ls-production-and-dev.js
@@ -17,10 +17,12 @@ var json = {
name: 'ls-env',
version: '0.0.0',
dependencies: {
- 'test-package-with-one-dep': '0.0.0'
+ 'test-package-with-one-dep': '0.0.0',
+ 'test-repo-url-ssh': '0.0.1'
},
devDependencies: {
- 'test-package-with-one-dep': '0.0.0'
+ 'test-package-with-one-dep': '0.0.0',
+ 'test-repo-url-https': '0.0.1'
}
}
@@ -57,6 +59,16 @@ test('npm ls --dev', function (t) {
/test-package-with-one-dep@0\.0\.0/,
'output contains test-package-with-one-dep@0.0.0'
)
+ t.has(
+ stdout,
+ /test-repo-url-https@0\.0\.1/,
+ 'output contains test-repo-url-https@0.0.1'
+ )
+ t.doesNotHave(
+ stdout,
+ /test-repo-url-ssh@0\.0\.1/,
+ 'output does NOT contain test-repo-url-ssh@0.0.1'
+ )
t.end()
})
})
@@ -96,6 +108,16 @@ test('npm ls --production', function (t) {
/test-package-with-one-dep@0\.0\.0/,
'output contains test-package-with-one-dep@0.0.0'
)
+ t.has(
+ stdout,
+ /test-repo-url-ssh@0\.0\.1/,
+ 'output contains test-repo-url-ssh@0.0.1'
+ )
+ t.doesNotHave(
+ stdout,
+ /test-repo-url-https@0\.0\.1/,
+ 'output does NOT contain test-repo-url-https@0.0.1'
+ )
t.end()
})
})
diff --git a/deps/npm/test/tap/map-to-registry.js b/deps/npm/test/tap/map-to-registry.js
index 9f6673b92c..d9677bd7e0 100644
--- a/deps/npm/test/tap/map-to-registry.js
+++ b/deps/npm/test/tap/map-to-registry.js
@@ -48,7 +48,7 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/design/-/rewrite/')
})
@@ -66,7 +66,7 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/-/rewrite/')
})
@@ -84,8 +84,83 @@ test('mapRegistryToURI', function (t) {
password: undefined,
email: undefined,
auth: undefined,
- alwaysAuth: undefined
+ alwaysAuth: false
})
t.equal(registry, 'http://reg.npm/design/-/rewrite/relative/')
})
})
+
+test('mapToRegistry token scoping', function (t) {
+ npm.config.set('scope', '')
+ npm.config.set('registry', 'https://reg.npm/')
+ npm.config.set('//reg.npm/:_authToken', 'r-token')
+
+ t.test('pass token to registry host', function (t) {
+ mapRegistry(
+ 'https://reg.npm/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://reg.npm/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: 'r-token',
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: false
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.test("don't pass token to non-registry host", function (t) {
+ mapRegistry(
+ 'https://butts.lol/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://butts.lol/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: undefined,
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: false
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.test('pass token to non-registry host with always-auth', function (t) {
+ npm.config.set('always-auth', true)
+ mapRegistry(
+ 'https://butts.lol/packages/e/easy-1.0.0.tgz',
+ npm.config,
+ function (er, uri, auth, registry) {
+ t.ifError(er, 'mapRegistryToURI worked')
+ t.equal(uri, 'https://butts.lol/packages/e/easy-1.0.0.tgz')
+ t.deepEqual(auth, {
+ scope: '//reg.npm/',
+ token: 'r-token',
+ username: undefined,
+ password: undefined,
+ email: undefined,
+ auth: undefined,
+ alwaysAuth: true
+ })
+ t.equal(registry, 'https://reg.npm/')
+ }
+ )
+ t.end()
+ })
+
+ t.end()
+})
diff --git a/deps/npm/test/tap/progress-config.js b/deps/npm/test/tap/progress-config.js
index 4b6f806dd3..acddc0d07b 100644
--- a/deps/npm/test/tap/progress-config.js
+++ b/deps/npm/test/tap/progress-config.js
@@ -11,6 +11,10 @@ var requireInject = require('require-inject')
// Make sure existing environment vars don't muck up the test
process.env = {}
+function hasOnlyAscii (s) {
+ return /^[\000-\177]*$/.test(s)
+}
+
test('disabled', function (t) {
t.plan(1)
var npm = requireInject('../../lib/npm.js', {})
@@ -54,3 +58,23 @@ test('default-ci', function (t) {
delete global.process.env.CI
})
})
+
+test('unicode-true', function (t) {
+ t.plan(6)
+ var npm = requireInject('../../lib/npm.js', {})
+ npm.load({unicode: true}, function () {
+ Object.keys(log.gauge.theme).forEach(function (key) {
+ t.notOk(hasOnlyAscii(log.gauge.theme[key]), 'only unicode')
+ })
+ })
+})
+
+test('unicode-false', function (t) {
+ t.plan(6)
+ var npm = requireInject('../../lib/npm.js', {})
+ npm.load({unicode: false}, function () {
+ Object.keys(log.gauge.theme).forEach(function (key) {
+ t.ok(hasOnlyAscii(log.gauge.theme[key]), 'only ASCII')
+ })
+ })
+})
diff --git a/deps/npm/test/tap/run-script.js b/deps/npm/test/tap/run-script.js
index d7087693df..3892337cee 100644
--- a/deps/npm/test/tap/run-script.js
+++ b/deps/npm/test/tap/run-script.js
@@ -25,8 +25,13 @@ var fullyPopulated = {
'prewith-both': 'node -e "console.log(process.argv[1] || \'pre\')"',
'with-both': 'node -e "console.log(process.argv[1] || \'main\')"',
'postwith-both': 'node -e "console.log(process.argv[1] || \'post\')"',
- 'stop': 'node -e "console.log(process.argv[1] || \'stop\')"'
- }
+ 'stop': 'node -e "console.log(process.argv[1] || \'stop\')"',
+ 'env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
+ 'npm-env-vars': 'node -e "console.log(process.env.npm_run_script_foo_var)"',
+ 'package-env-vars': 'node -e "console.log(process.env.run_script_foo_var)"',
+ 'prefixed-package-env-vars': 'node -e "console.log(process.env.npm_package_run_script_foo_var)"'
+ },
+ 'run_script_foo_var': 'run_script_test_foo_val'
}
var lifecycleOnly = {
@@ -180,6 +185,64 @@ test('npm run-script nonexistent-script with --if-present flag', function (t) {
})
})
+test('npm run-script env vars accessible', function (t) {
+ process.env.run_script_foo_var = 'run_script_test_foo_val'
+ common.npm(['run-script', 'env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(process.env.run_script_foo_var),
+ 'script had env access')
+ t.end()
+ })
+})
+
+test('npm run-script package.json vars injected', function (t) {
+ common.npm(['run-script', 'package-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(fullyPopulated.run_script_foo_var),
+ 'script injected package.json value')
+ t.end()
+ })
+})
+
+test('npm run-script package.json vars injected with prefix', function (t) {
+ common.npm(['run-script', 'prefixed-package-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.match(stdout,
+ new RegExp(fullyPopulated.run_script_foo_var),
+ 'script injected npm_package-prefixed package.json value')
+ t.end()
+ })
+})
+
+test('npm run-script env vars stripped npm-prefixed', function (t) {
+ process.env.npm_run_script_foo_var = 'run_script_test_foo_val'
+ common.npm(['run-script', 'npm-env-vars'], {
+ cwd: pkg
+ }, function (err, code, stdout, stderr) {
+ t.ifError(err, 'ran run-script without crashing')
+ t.equal(code, 0, 'exited normally')
+ t.equal(stderr, '', 'no error output')
+ t.notMatch(stdout,
+ new RegExp(process.env.npm_run_script_foo_var),
+ 'script stripped npm-prefixed env var')
+ t.end()
+ })
+})
+
test('npm run-script no-params (lifecycle only)', function (t) {
var expected = [
'Lifecycle scripts included in scripted:',
diff --git a/deps/npm/test/tap/shrinkwrap-scoped-auth.js b/deps/npm/test/tap/shrinkwrap-scoped-auth.js
index 8fe0d1e23e..63fd08cb07 100644
--- a/deps/npm/test/tap/shrinkwrap-scoped-auth.js
+++ b/deps/npm/test/tap/shrinkwrap-scoped-auth.js
@@ -50,7 +50,6 @@ test('authed npm install with shrinkwrapped scoped package', function (t) {
],
EXEC_OPTS,
function (err, code, stdout, stderr) {
- console.error(stderr)
t.ifError(err, 'test runner executed without error')
t.equal(code, 0, 'npm install exited OK')
t.notOk(stderr, 'no output on stderr')
diff --git a/deps/npm/test/tap/update-symlink.js b/deps/npm/test/tap/update-symlink.js
new file mode 100644
index 0000000000..1447fde628
--- /dev/null
+++ b/deps/npm/test/tap/update-symlink.js
@@ -0,0 +1,91 @@
+var fs = require('graceful-fs')
+var path = require('path')
+var osenv = require('osenv')
+var mkdirp = require('mkdirp')
+var mr = require('npm-registry-mock')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap.js')
+
+var pkg = path.resolve(__dirname, 'update-symlink')
+var originalLog
+
+var fakeRoot = path.join(__dirname, 'fakeRoot')
+var OPTS = {
+ env: {
+ 'npm_config_prefix': fakeRoot
+ }
+}
+
+var jsonLocal = {
+ name: 'my-local-package',
+ description: 'fixture',
+ version: '1.0.0',
+ dependencies: {
+ 'async': '*',
+ 'underscore': '*'
+ }
+}
+
+test('setup', function (t) {
+ cleanup()
+ originalLog = console.log
+ mkdirp.sync(pkg)
+ common.npm(['install', '-g', 'underscore@1.3.1'], OPTS, function (err, c, out) {
+ t.ifError(err, 'global install did not error')
+ process.chdir(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(jsonLocal, null, 2)
+ )
+ common.npm(['link', 'underscore'], OPTS, function (err, c, out) {
+ t.ifError(err, 'link did not error')
+ common.npm(['install', 'async@0.2.9'], OPTS, function (err, c, out) {
+ t.ifError(err, 'local install did not error')
+ common.npm(['ls'], OPTS, function (err, c, out, stderr) {
+ t.ifError(err)
+ t.equal(c, 0)
+ t.equal(stderr, '', 'got expected stderr')
+ t.has(out, /async@0.2.9/, 'installed ok')
+ t.has(out, /underscore@1.3.1/, 'creates local link ok')
+ t.end()
+ })
+ })
+ })
+ })
+})
+
+test('when update is called linked packages should be excluded', function (t) {
+ console.log = function () {}
+ mr({ port: common.port }, function (er, s) {
+ common.npm(['update'], OPTS, function (err, c, out, stderr) {
+ t.ifError(err)
+ t.has(out, /async@1.5.2/, 'updated ok')
+ t.doesNotHave(stderr, /ERR!/, 'no errors in stderr')
+ s.close()
+ t.end()
+ })
+ })
+})
+
+test('cleanup', function (t) {
+ common.npm(['rm', 'underscore', 'async'], OPTS, function (err, code) {
+ t.ifError(err, 'npm removed the linked package without error')
+ t.equal(code, 0, 'cleanup in local ok')
+ process.chdir(osenv.tmpdir())
+ common.npm(['rm', '-g', 'underscore'], OPTS, function (err, code) {
+ t.ifError(err, 'npm removed the global package without error')
+ t.equal(code, 0, 'cleanup in global ok')
+
+ console.log = originalLog
+ cleanup()
+ t.end()
+ })
+ })
+})
+
+function cleanup () {
+ rimraf.sync(pkg)
+ rimraf.sync(fakeRoot)
+}
diff --git a/deps/npm/test/tap/view.js b/deps/npm/test/tap/view.js
index f54fe93a18..8c5c901ab2 100644
--- a/deps/npm/test/tap/view.js
+++ b/deps/npm/test/tap/view.js
@@ -153,7 +153,7 @@ test('npm view .@<version>', function (t) {
})
})
-test('npm view .@<version> --json', function (t) {
+test('npm view .@<version> version --json', function (t) {
process.chdir(t2dir)
mr({ port: common.port, plugin: plugin }, function (er, s) {
common.npm([
@@ -172,6 +172,58 @@ test('npm view .@<version> --json', function (t) {
})
})
+test('npm view . --json author name version', function (t) {
+ process.chdir(t2dir)
+ mr({ port: common.port, plugin: plugin }, function (er, s) {
+ common.npm([
+ 'view',
+ '.',
+ 'author',
+ 'name',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ var expected = JSON.stringify({
+ author: 'Evan Lucas <evanlucas@me.com>',
+ name: 'test-repo-url-https',
+ version: '0.0.1'
+ }, null, 2)
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), expected, 'should print ' + expected)
+ s.close()
+ t.end()
+ })
+ })
+})
+
+test('npm view .@<version> --json author name version', function (t) {
+ process.chdir(t2dir)
+ mr({ port: common.port, plugin: plugin }, function (er, s) {
+ common.npm([
+ 'view',
+ '.@0.0.0',
+ 'author',
+ 'name',
+ 'version',
+ '--json',
+ '--registry=' + common.registry
+ ], { cwd: t2dir }, function (err, code, stdout) {
+ var expected = JSON.stringify({
+ author: 'Evan Lucas <evanlucas@me.com>',
+ name: 'test-repo-url-https',
+ version: '0.0.0'
+ }, null, 2)
+ t.ifError(err, 'view command finished successfully')
+ t.equal(code, 0, 'exit ok')
+ t.equal(stdout.trim(), expected, 'should print ' + expected)
+ s.close()
+ t.end()
+ })
+ })
+})
+
test('npm view <package name>', function (t) {
mr({ port: common.port, plugin: plugin }, function (er, s) {
common.npm([