mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 04:10:04 +02:00
update packages to latest version
This commit is contained in:
97
node_modules/npm/test/common-tap.js
generated
vendored
Normal file
97
node_modules/npm/test/common-tap.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// cheesy hackaround for test deps (read: nock) that rely on setImmediate
|
||||
if (!global.setImmediate || !require('timers').setImmediate) {
|
||||
require('timers').setImmediate = global.setImmediate = function () {
|
||||
var args = [arguments[0], 0].concat([].slice.call(arguments, 1))
|
||||
setTimeout.apply(this, args)
|
||||
}
|
||||
}
|
||||
var spawn = require('child_process').spawn
|
||||
var path = require('path')
|
||||
|
||||
var port = exports.port = 1337
|
||||
exports.registry = 'http://localhost:' + port
|
||||
process.env.npm_config_loglevel = 'error'
|
||||
|
||||
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.random_env_var = 'foo'
|
||||
// suppress warnings about using a prerelease version of node
|
||||
process.env.npm_config_node_version = process.version.replace(/-.*$/, '')
|
||||
|
||||
var bin = exports.bin = require.resolve('../bin/npm-cli.js')
|
||||
var chain = require('slide').chain
|
||||
var once = require('once')
|
||||
|
||||
exports.npm = function npm (cmd, opts, cb) {
|
||||
cb = once(cb)
|
||||
cmd = [bin].concat(cmd)
|
||||
opts = opts || {}
|
||||
|
||||
opts.env = opts.env || process.env
|
||||
if (!opts.env.npm_config_cache) {
|
||||
opts.env.npm_config_cache = npm_config_cache
|
||||
}
|
||||
|
||||
var stdout = ''
|
||||
var stderr = ''
|
||||
var node = process.execPath
|
||||
var child = spawn(node, cmd, opts)
|
||||
|
||||
if (child.stderr) {
|
||||
child.stderr.on('data', function (chunk) {
|
||||
stderr += chunk
|
||||
})
|
||||
}
|
||||
|
||||
if (child.stdout) {
|
||||
child.stdout.on('data', function (chunk) {
|
||||
stdout += chunk
|
||||
})
|
||||
}
|
||||
|
||||
child.on('error', cb)
|
||||
|
||||
child.on('close', function (code) {
|
||||
cb(null, code, stdout, stderr)
|
||||
})
|
||||
return child
|
||||
}
|
||||
|
||||
exports.makeGitRepo = function makeGitRepo (params, cb) {
|
||||
// git must be called after npm.load because it uses config
|
||||
var git = require('../lib/utils/git.js')
|
||||
|
||||
var root = params.path || process.cwd()
|
||||
var user = params.user || 'PhantomFaker'
|
||||
var email = params.email || 'nope@not.real'
|
||||
var added = params.added || ['package.json']
|
||||
var message = params.message || 'stub repo'
|
||||
|
||||
var opts = { cwd: root, env: { PATH: process.env.PATH }}
|
||||
var commands = [
|
||||
git.chainableExec(['init'], opts),
|
||||
git.chainableExec(['config', 'user.name', user], opts),
|
||||
git.chainableExec(['config', 'user.email', email], opts),
|
||||
git.chainableExec(['add'].concat(added), opts),
|
||||
git.chainableExec(['commit', '-m', message], opts)
|
||||
]
|
||||
|
||||
if (Array.isArray(params.commands)) {
|
||||
commands = commands.concat(params.commands)
|
||||
}
|
||||
|
||||
chain(commands, cb)
|
||||
}
|
||||
|
||||
exports.rmFromInShrinkwrap = function rmFromInShrinkwrap (obj) {
|
||||
for (var i in obj) {
|
||||
if (i === "from")
|
||||
delete obj[i]
|
||||
else if (i === "dependencies")
|
||||
for (var j in obj[i])
|
||||
exports.rmFromInShrinkwrap(obj[i][j])
|
||||
}
|
||||
return obj
|
||||
}
|
1
node_modules/npm/test/fixtures/config/builtin
generated
vendored
Normal file
1
node_modules/npm/test/fixtures/config/builtin
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
builtin-config = true
|
1
node_modules/npm/test/fixtures/config/globalconfig
generated
vendored
Normal file
1
node_modules/npm/test/fixtures/config/globalconfig
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
package-config:foo = boo
|
1
node_modules/npm/test/fixtures/config/malformed
generated
vendored
Normal file
1
node_modules/npm/test/fixtures/config/malformed
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
email = """
|
32
node_modules/npm/test/fixtures/config/multi-ca
generated
vendored
Normal file
32
node_modules/npm/test/fixtures/config/multi-ca
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICjTCCAfigAwIBAgIEMaYgRzALBgkqhkiG9w0BAQQwRTELMAkGA1UEBhMCVVMx
|
||||
NjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFuZCBTcGFjZSBBZG1pbmlz
|
||||
dHJhdGlvbjAmFxE5NjA1MjgxMzQ5MDUrMDgwMBcROTgwNTI4MTM0OTA1KzA4MDAw
|
||||
ZzELMAkGA1UEBhMCVVMxNjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFu
|
||||
ZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEgMAkGA1UEBRMCMTYwEwYDVQQDEwxTdGV2
|
||||
ZSBTY2hvY2gwWDALBgkqhkiG9w0BAQEDSQAwRgJBALrAwyYdgxmzNP/ts0Uyf6Bp
|
||||
miJYktU/w4NG67ULaN4B5CnEz7k57s9o3YY3LecETgQ5iQHmkwlYDTL2fTgVfw0C
|
||||
AQOjgaswgagwZAYDVR0ZAQH/BFowWDBWMFQxCzAJBgNVBAYTAlVTMTYwNAYDVQQK
|
||||
Ey1OYXRpAAAAACBBZXJvbmF1dGljcyBhbmQgU3BhY2UgQWRtaW5pc3RyYXRpb24x
|
||||
DTALBgNVBAMTBENSTDEwFwYDVR0BAQH/BA0wC4AJODMyOTcwODEwMBgGA1UdAgQR
|
||||
MA8ECTgzMjk3MDgyM4ACBSAwDQYDVR0KBAYwBAMCBkAwCwYJKoZIhvcNAQEEA4GB
|
||||
AH2y1VCEw/A4zaXzSYZJTTUi3uawbbFiS2yxHvgf28+8Js0OHXk1H1w2d6qOHH21
|
||||
X82tZXd/0JtG0g1T9usFFBDvYK8O0ebgz/P5ELJnBL2+atObEuJy1ZZ0pBDWINR3
|
||||
WkDNLCGiTkCKp0F5EWIrVDwh54NNevkCQRZita+z4IBO
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
AAAAAACCAfigAwIBAgIEMaYgRzALBgkqhkiG9w0BAQQwRTELMAkGA1UEBhMCVVMx
|
||||
NjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFuZCBTcGFjZSBBZG1pbmlz
|
||||
dHJhdGlvbjAmFxE5NjA1MjgxMzQ5MDUrMDgwMBcROTgwNTI4MTM0OTA1KzA4MDAw
|
||||
ZzELMAkGA1UEBhMCVVMxNjA0BgNVBAoTLU5hdGlvbmFsIEFlcm9uYXV0aWNzIGFu
|
||||
ZCBTcGFjZSBBZG1pbmlzdHJhdGlvbjEgMAkGA1UEBRMCMTYwEwYDVQQDEwxTdGV2
|
||||
ZSBTY2hvY2gwWDALBgkqhkiG9w0BAQEDSQAwRgJBALrAwyYdgxmzNP/ts0Uyf6Bp
|
||||
miJYktU/w4NG67ULaN4B5CnEz7k57s9o3YY3LecETgQ5iQHmkwlYDTL2fTgVfw0C
|
||||
AQOjgaswgagwZAYDVR0ZAQH/BFowWDBWMFQxCzAJBgNVBAYTAlVTMTYwNAYDVQQK
|
||||
Ey1OYXRpb25hbCBBZXJvbmF1dGljcyBhbmQgU3BhY2UgQWRtaW5pc3RyYXRpb24x
|
||||
DTALBgNVBAMTBENSTDEwFwYDVR0BAQH/BA0wC4AJODMyOTcwODEwMBgGA1UdAgQR
|
||||
MA8ECTgzMjk3MDgyM4ACBSAwDQYDVR0KBAYwBAMCBkAwCwYJKoZIhvcNAQEEA4GB
|
||||
AH2y1VCEw/A4zaXzSYZJTTUi3uawbbFiS2yxHvgf28+8Js0OHXk1H1w2d6qOHH21
|
||||
X82tZXd/0JtG0g1T9usFFBDvYK8O0ebgz/P5ELJnBL2+atObEuJy1ZZ0pBDWINR3
|
||||
WkDNLCGiTkCKp0F5EWIrVDwh54NNevkCQRZita+z4IBO
|
||||
-----END CERTIFICATE-----
|
0
node_modules/npm/test/fixtures/config/package.json
generated
vendored
Normal file
0
node_modules/npm/test/fixtures/config/package.json
generated
vendored
Normal file
23
node_modules/npm/test/fixtures/config/userconfig
generated
vendored
Normal file
23
node_modules/npm/test/fixtures/config/userconfig
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
email = i@izs.me
|
||||
env-thing = ${random_env_var}
|
||||
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
|
||||
nodedir = /Users/isaacs/dev/js/node-v0.8
|
||||
sign-git-tag = true
|
||||
message = v%s
|
||||
strict-ssl = false
|
||||
tmp = ~/.tmp
|
||||
_auth = dXNlcm5hbWU6cGFzc3dvcmQ=
|
||||
|
||||
[_token]
|
||||
AuthSession = yabba-dabba-doodle
|
||||
version = 1
|
||||
expires = 1345001053415
|
||||
path = /
|
||||
httponly = true
|
BIN
node_modules/npm/test/fixtures/forked-underscore-1.5.1.tgz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/forked-underscore-1.5.1.tgz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-bar.git.tar.gz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-bar.git.tar.gz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-buzz.git.tar.gz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-buzz.git.tar.gz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-foo.git.tar.gz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-dummy-npm-foo.git.tar.gz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-npm-git-test.git.tar.gz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/github-com-BryanDonovan-npm-git-test.git.tar.gz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore-2.tar
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore-2.tar
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore.tar
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore.tar
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore.tgz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/gitignore-and-npmignore.tgz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/gitignore.tgz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/gitignore.tgz
generated
vendored
Normal file
Binary file not shown.
BIN
node_modules/npm/test/fixtures/npmignore.tgz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/npmignore.tgz
generated
vendored
Normal file
Binary file not shown.
1
node_modules/npm/test/fixtures/onload.js
generated
vendored
Normal file
1
node_modules/npm/test/fixtures/onload.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.error('called onload')
|
BIN
node_modules/npm/test/fixtures/scoped-underscore-1.3.1.tgz
generated
vendored
Normal file
BIN
node_modules/npm/test/fixtures/scoped-underscore-1.3.1.tgz
generated
vendored
Normal file
Binary file not shown.
4
node_modules/npm/test/packages/npm-test-array-bin/test.js
generated
vendored
Normal file
4
node_modules/npm/test/packages/npm-test-array-bin/test.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
require('child_process').exec('array-bin', { env: process.env },
|
||||
function (err) {
|
||||
if (err && err.code) throw new Error('exited badly with code = ' + err.code)
|
||||
})
|
5
node_modules/npm/test/packages/npm-test-blerg/test.js
generated
vendored
Normal file
5
node_modules/npm/test/packages/npm-test-blerg/test.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
var assert = require("assert")
|
||||
assert.equal(undefined, process.env.npm_config__password, "password exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__auth, "auth exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__authCrypt, "authCrypt exposed!")
|
5
node_modules/npm/test/packages/npm-test-blerg3/test.js
generated
vendored
Normal file
5
node_modules/npm/test/packages/npm-test-blerg3/test.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
var assert = require("assert")
|
||||
assert.equal(undefined, process.env.npm_config__password, "password exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__auth, "auth exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__authCrypt, "authCrypt exposed!")
|
29
node_modules/npm/test/packages/npm-test-bundled-git/minimatch-expected.json
generated
vendored
Normal file
29
node_modules/npm/test/packages/npm-test-bundled-git/minimatch-expected.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
4
node_modules/npm/test/packages/npm-test-bundled-git/test.js
generated
vendored
Normal file
4
node_modules/npm/test/packages/npm-test-bundled-git/test.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var a = require("./node_modules/glob/node_modules/minimatch/package.json")
|
||||
var e = require("./minimatch-expected.json")
|
||||
var assert = require("assert")
|
||||
assert.deepEqual(a, e, "didn't get expected minimatch/package.json")
|
4
node_modules/npm/test/packages/npm-test-dir-bin/test.js
generated
vendored
Normal file
4
node_modules/npm/test/packages/npm-test-dir-bin/test.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
require('child_process').exec('dir-bin', { stdio: 'pipe',
|
||||
env: process.env }, function (err) {
|
||||
if (err && err.code) throw new Error('exited badly with code = ' + err.code)
|
||||
})
|
2
node_modules/npm/test/packages/npm-test-ignore-nested-nm/test.js
generated
vendored
Normal file
2
node_modules/npm/test/packages/npm-test-ignore-nested-nm/test.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
fs = require('fs')
|
||||
fs.statSync(__dirname + '/lib/node_modules/foo')
|
5
node_modules/npm/test/packages/npm-test-missing-bindir/test.js
generated
vendored
Normal file
5
node_modules/npm/test/packages/npm-test-missing-bindir/test.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
var assert = require("assert")
|
||||
assert.equal(undefined, process.env.npm_config__password, "password exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__auth, "auth exposed!")
|
||||
assert.equal(undefined, process.env.npm_config__authCrypt, "authCrypt exposed!")
|
9
node_modules/npm/test/packages/npm-test-optional-deps/test.js
generated
vendored
Normal file
9
node_modules/npm/test/packages/npm-test-optional-deps/test.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var fs = require("fs")
|
||||
var assert = require("assert")
|
||||
var path = require("path")
|
||||
|
||||
// sax should be the only dep that ends up installed
|
||||
|
||||
var dir = path.resolve(__dirname, "node_modules")
|
||||
assert.deepEqual(fs.readdirSync(dir), ["sax"])
|
||||
assert.equal(require("sax/package.json").version, "0.3.5")
|
48
node_modules/npm/test/packages/npm-test-shrinkwrap/npm-shrinkwrap.json
generated
vendored
Normal file
48
node_modules/npm/test/packages/npm-test-shrinkwrap/npm-shrinkwrap.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "npm-test-shrinkwrap",
|
||||
"version": "0.0.0",
|
||||
"dependencies": {
|
||||
"npm-test-single-file": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://gist.github.com/isaacs/1837112/raw/9ef57a59fc22aeb1d1ca346b68826dcb638b8416/index.js"
|
||||
},
|
||||
"glob": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "git://github.com/isaacs/node-glob.git#67bda227fd7a559cca5620307c7d30a6732a792f",
|
||||
"dependencies": {
|
||||
"minimatch": {
|
||||
"version": "0.2.1",
|
||||
"dependencies": {
|
||||
"lru-cache": {
|
||||
"version": "1.0.5"
|
||||
}
|
||||
}
|
||||
},
|
||||
"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.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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
193
node_modules/npm/test/run.js
generated
vendored
Normal file
193
node_modules/npm/test/run.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
// Everything in this file uses child processes, because we're
|
||||
// testing a command line utility.
|
||||
|
||||
var chain = require("slide").chain
|
||||
var child_process = require("child_process")
|
||||
var path = require("path")
|
||||
, testdir = __dirname
|
||||
, fs = require("graceful-fs")
|
||||
, npmpkg = path.dirname(testdir)
|
||||
, npmcli = path.resolve(npmpkg, "bin", "npm-cli.js")
|
||||
|
||||
var temp = process.env.TMPDIR
|
||||
|| process.env.TMP
|
||||
|| process.env.TEMP
|
||||
|| ( process.platform === "win32"
|
||||
? "c:\\windows\\temp"
|
||||
: "/tmp" )
|
||||
|
||||
temp = path.resolve(temp, "npm-test-" + process.pid)
|
||||
|
||||
var root = path.resolve(temp, "root")
|
||||
, cache = path.resolve(temp, "npm_cache")
|
||||
|
||||
var failures = 0
|
||||
, mkdir = require("mkdirp")
|
||||
, rimraf = require("rimraf")
|
||||
|
||||
var pathEnvSplit = process.platform === "win32" ? ";" : ":"
|
||||
, pathEnv = process.env.PATH.split(pathEnvSplit)
|
||||
, npmPath = process.platform === "win32" ? root : path.join(root, "bin")
|
||||
|
||||
pathEnv.unshift(npmPath, path.join(root, "node_modules", ".bin"))
|
||||
|
||||
// lastly, make sure that we get the same node that is being used to do
|
||||
// run this script. That's very important, especially when running this
|
||||
// test file from in the node source folder.
|
||||
pathEnv.unshift(path.dirname(process.execPath))
|
||||
|
||||
// the env for all the test installs etc.
|
||||
var env = {}
|
||||
Object.keys(process.env).forEach(function (i) {
|
||||
env[i] = process.env[i]
|
||||
})
|
||||
env.npm_config_prefix = root
|
||||
env.npm_config_color = "always"
|
||||
env.npm_config_global = "true"
|
||||
// have to set this to false, or it'll try to test itself forever
|
||||
env.npm_config_npat = "false"
|
||||
env.PATH = pathEnv.join(pathEnvSplit)
|
||||
env.NODE_PATH = path.join(root, "node_modules")
|
||||
env.npm_config_cache = cache
|
||||
|
||||
|
||||
|
||||
function cleanup (cb) {
|
||||
if (failures !== 0) return
|
||||
rimraf(root, function (er) {
|
||||
if (er) cb(er)
|
||||
mkdir(root, 0755, cb)
|
||||
})
|
||||
}
|
||||
|
||||
function prefix (content, pref) {
|
||||
return pref + (content.trim().split(/\r?\n/).join("\n" + pref))
|
||||
}
|
||||
|
||||
var execCount = 0
|
||||
function exec (cmd, cwd, shouldFail, cb) {
|
||||
if (typeof shouldFail === "function") {
|
||||
cb = shouldFail, shouldFail = false
|
||||
}
|
||||
console.error("\n+"+cmd + (shouldFail ? " (expect failure)" : ""))
|
||||
|
||||
// special: replace 'node' with the current execPath,
|
||||
// and 'npm' with the thing we installed.
|
||||
var cmdShow = cmd
|
||||
var npmReplace = path.resolve(npmPath, "npm")
|
||||
var nodeReplace = process.execPath
|
||||
if (process.platform === "win32") {
|
||||
npmReplace = '"' + npmReplace + '"'
|
||||
nodeReplace = '"' + nodeReplace + '"'
|
||||
}
|
||||
cmd = cmd.replace(/^npm /, npmReplace + " ")
|
||||
cmd = cmd.replace(/^node /, nodeReplace + " ")
|
||||
|
||||
console.error("$$$$$$ cd %s; PATH=%s %s", cwd, env.PATH, cmd)
|
||||
|
||||
child_process.exec(cmd, {cwd: cwd, env: env}, function (er, stdout, stderr) {
|
||||
console.error("$$$$$$ after command", cmd, cwd)
|
||||
if (stdout) {
|
||||
console.error(prefix(stdout, " 1> "))
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(prefix(stderr, " 2> "))
|
||||
}
|
||||
|
||||
execCount ++
|
||||
if (!shouldFail && !er || shouldFail && er) {
|
||||
// stdout = (""+stdout).trim()
|
||||
console.log("ok " + execCount + " " + cmdShow)
|
||||
return cb()
|
||||
} else {
|
||||
console.log("not ok " + execCount + " " + cmdShow)
|
||||
cb(new Error("failed "+cmdShow))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function execChain (cmds, cb) {
|
||||
chain(cmds.map(function (args) {
|
||||
return [exec].concat(args)
|
||||
}), cb)
|
||||
}
|
||||
|
||||
function flatten (arr) {
|
||||
return arr.reduce(function (l, r) {
|
||||
return l.concat(r)
|
||||
}, [])
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
cleanup(function (er) {
|
||||
if (er) return cb(er)
|
||||
exec("node \""+npmcli+"\" install \""+npmpkg+"\"", root, false, cb)
|
||||
})
|
||||
}
|
||||
|
||||
function main (cb) {
|
||||
console.log("# testing in %s", temp)
|
||||
console.log("# global prefix = %s", root)
|
||||
|
||||
|
||||
|
||||
failures = 0
|
||||
|
||||
process.chdir(testdir)
|
||||
var base = path.resolve(root, path.join("lib", "node_modules"))
|
||||
|
||||
// get the list of packages
|
||||
var packages = fs.readdirSync(path.resolve(testdir, "packages"))
|
||||
packages = packages.filter(function (p) {
|
||||
return p && !p.match(/^\./)
|
||||
})
|
||||
|
||||
installAllThenTestAll()
|
||||
|
||||
function installAllThenTestAll () {
|
||||
var packagesToRm = packages.slice(0)
|
||||
if (process.platform !== "win32") {
|
||||
// Windows can't handle npm rm npm due to file-in-use issues.
|
||||
packagesToRm.push("npm")
|
||||
}
|
||||
|
||||
chain(
|
||||
[ setup
|
||||
, [ exec, "npm install "+npmpkg, testdir ]
|
||||
, [ execChain, packages.map(function (p) {
|
||||
return [ "npm install packages/"+p, testdir ]
|
||||
}) ]
|
||||
, [ execChain, packages.map(function (p) {
|
||||
return [ "npm test -ddd", path.resolve(base, p) ]
|
||||
}) ]
|
||||
, [ execChain, packagesToRm.map(function (p) {
|
||||
return [ "npm rm "+p, root ]
|
||||
}) ]
|
||||
, installAndTestEach
|
||||
]
|
||||
, cb
|
||||
)
|
||||
}
|
||||
|
||||
function installAndTestEach (cb) {
|
||||
var thingsToChain = [
|
||||
setup
|
||||
, [ execChain, flatten(packages.map(function (p) {
|
||||
return [ [ "npm install packages/"+p, testdir ]
|
||||
, [ "npm test", path.resolve(base, p) ]
|
||||
, [ "npm rm "+p, root ] ]
|
||||
})) ]
|
||||
]
|
||||
if (process.platform !== "win32") {
|
||||
// Windows can't handle npm rm npm due to file-in-use issues.
|
||||
thingsToChain.push([exec, "npm rm npm", testdir])
|
||||
}
|
||||
|
||||
chain(thingsToChain, cb)
|
||||
}
|
||||
}
|
||||
|
||||
main(function (er) {
|
||||
console.log("1.." + execCount)
|
||||
if (er) throw er
|
||||
})
|
17
node_modules/npm/test/tap/00-check-mock-dep.js
generated
vendored
Normal file
17
node_modules/npm/test/tap/00-check-mock-dep.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
console.log("TAP Version 13")
|
||||
|
||||
process.on("uncaughtException", function (er) {
|
||||
if (er) { throw er }
|
||||
console.log("not ok - Failed checking mock registry dep. Expect much fail!")
|
||||
console.log("1..1")
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
var assert = require("assert")
|
||||
var semver = require("semver")
|
||||
var mock = require("npm-registry-mock/package.json").version
|
||||
var req = require("../../package.json").devDependencies["npm-registry-mock"]
|
||||
|
||||
assert(semver.satisfies(mock, req))
|
||||
console.log("ok")
|
||||
console.log("1..1")
|
83
node_modules/npm/test/tap/00-config-setup.js
generated
vendored
Normal file
83
node_modules/npm/test/tap/00-config-setup.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
var fs = require("graceful-fs")
|
||||
var path = require("path")
|
||||
var userconfigSrc = path.resolve(__dirname, "..", "fixtures", "config", "userconfig")
|
||||
exports.userconfig = userconfigSrc + "-with-gc"
|
||||
exports.globalconfig = path.resolve(__dirname, "..", "fixtures", "config", "globalconfig")
|
||||
exports.builtin = path.resolve(__dirname, "..", "fixtures", "config", "builtin")
|
||||
exports.malformed = path.resolve(__dirname, "..", "fixtures", "config", "malformed")
|
||||
exports.ucData =
|
||||
{ globalconfig: exports.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",
|
||||
nodedir: "/Users/isaacs/dev/js/node-v0.8",
|
||||
"sign-git-tag": true,
|
||||
message: "v%s",
|
||||
"strict-ssl": false,
|
||||
"tmp": process.env.HOME + "/.tmp",
|
||||
_auth: "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
_token:
|
||||
{ AuthSession: "yabba-dabba-doodle",
|
||||
version: "1",
|
||||
expires: "1345001053415",
|
||||
path: "/",
|
||||
httponly: true } }
|
||||
|
||||
// set the userconfig in the env
|
||||
// unset anything else that npm might be trying to foist on us
|
||||
Object.keys(process.env).forEach(function (k) {
|
||||
if (k.match(/^npm_config_/i)) {
|
||||
delete process.env[k]
|
||||
}
|
||||
})
|
||||
process.env.npm_config_userconfig = exports.userconfig
|
||||
process.env.npm_config_other_env_thing = 1000
|
||||
process.env.random_env_var = "asdf"
|
||||
process.env.npm_config__underbar_env_thing = "underful"
|
||||
process.env.NPM_CONFIG_UPPERCASE_ENV_THING = 42
|
||||
|
||||
exports.envData = {
|
||||
userconfig: exports.userconfig,
|
||||
"_underbar-env-thing": "underful",
|
||||
"uppercase-env-thing": "42",
|
||||
"other-env-thing": "1000"
|
||||
}
|
||||
exports.envDataFix = {
|
||||
userconfig: exports.userconfig,
|
||||
"_underbar-env-thing": "underful",
|
||||
"uppercase-env-thing": 42,
|
||||
"other-env-thing": 1000
|
||||
}
|
||||
|
||||
var projectConf = path.resolve(__dirname, '..', '..', '.npmrc')
|
||||
try {
|
||||
fs.statSync(projectConf)
|
||||
} catch (er) {
|
||||
// project conf not found, probably working with packed npm
|
||||
fs.writeFileSync(projectConf, 'save-prefix = ~\nproprietary-attribs = false\n')
|
||||
}
|
||||
|
||||
var projectRc = path.join(__dirname, '..', 'fixtures', 'config', '.npmrc')
|
||||
try {
|
||||
fs.statSync(projectRc)
|
||||
} catch (er) {
|
||||
// project conf not found, probably working with packed npm
|
||||
fs.writeFileSync(projectRc, 'just = testing')
|
||||
}
|
||||
|
||||
if (module === require.main) {
|
||||
// set the globalconfig in the userconfig
|
||||
var uc = fs.readFileSync(userconfigSrc)
|
||||
var gcini = "globalconfig = " + exports.globalconfig + "\n"
|
||||
fs.writeFileSync(exports.userconfig, gcini + uc)
|
||||
|
||||
console.log("1..1")
|
||||
console.log("ok 1 setup done")
|
||||
}
|
27
node_modules/npm/test/tap/00-verify-bundle-deps.js
generated
vendored
Normal file
27
node_modules/npm/test/tap/00-verify-bundle-deps.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var test = require("tap").test
|
||||
|
||||
var manifest = require("../../package.json")
|
||||
var deps = Object.keys(manifest.dependencies)
|
||||
var dev = Object.keys(manifest.devDependencies)
|
||||
var bundled = manifest.bundleDependencies
|
||||
|
||||
test("all deps are bundled deps or dev deps", function (t) {
|
||||
deps.forEach(function (name) {
|
||||
t.assert(
|
||||
bundled.indexOf(name) !== -1,
|
||||
name + " is in bundledDependencies"
|
||||
)
|
||||
})
|
||||
|
||||
t.same(
|
||||
fs.readdirSync(path.resolve(__dirname, "../../node_modules")).filter(function (name) {
|
||||
return (dev.indexOf(name) === -1) && (name !== ".bin")
|
||||
}).sort(),
|
||||
bundled.sort(),
|
||||
"bundleDependencies matches what's in node_modules"
|
||||
)
|
||||
|
||||
t.end()
|
||||
})
|
18
node_modules/npm/test/tap/00-verify-ls-ok.js
generated
vendored
Normal file
18
node_modules/npm/test/tap/00-verify-ls-ok.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var common = require("../common-tap")
|
||||
var test = require("tap").test
|
||||
var path = require("path")
|
||||
var cwd = path.resolve(__dirname, "..", "..")
|
||||
var fs = require("fs")
|
||||
|
||||
test("npm ls in npm", function (t) {
|
||||
t.ok(fs.existsSync(cwd), "ensure that the path we are calling ls within exists")
|
||||
var files = fs.readdirSync(cwd)
|
||||
t.notEqual(files.length, 0, "ensure there are files in the directory we are to ls")
|
||||
|
||||
var opt = { cwd: cwd, stdio: [ "ignore", "ignore", 2 ] }
|
||||
common.npm(["ls"], opt, function (err, code) {
|
||||
t.ifError(err, "error should not exist")
|
||||
t.equal(code, 0, "npm ls exited with code")
|
||||
t.end()
|
||||
})
|
||||
})
|
57
node_modules/npm/test/tap/404-parent.js
generated
vendored
Normal file
57
node_modules/npm/test/tap/404-parent.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var common = require("../common-tap.js")
|
||||
var test = require("tap").test
|
||||
var npm = require("../../")
|
||||
var osenv = require("osenv")
|
||||
var path = require("path")
|
||||
var fs = require("fs")
|
||||
var rimraf = require("rimraf")
|
||||
var mkdirp = require("mkdirp")
|
||||
var pkg = path.resolve(__dirname, "404-parent")
|
||||
var mr = require("npm-registry-mock")
|
||||
|
||||
test("404-parent: if parent exists, specify parent in error message", function (t) {
|
||||
setup()
|
||||
rimraf.sync(path.resolve(pkg, "node_modules"))
|
||||
performInstall(function (err) {
|
||||
t.ok(err instanceof Error, "error was returned")
|
||||
t.ok(err.parent === "404-parent-test", "error's parent set")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup() {
|
||||
mkdirp.sync(pkg)
|
||||
mkdirp.sync(path.resolve(pkg, "cache"))
|
||||
fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify({
|
||||
author: "Evan Lucas",
|
||||
name: "404-parent-test",
|
||||
version: "0.0.0",
|
||||
description: "Test for 404-parent",
|
||||
dependencies: {
|
||||
"test-npm-404-parent-test": "*"
|
||||
}
|
||||
}), "utf8")
|
||||
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 () {
|
||||
npm.commands.install(pkg, [], function (err) {
|
||||
cb(err)
|
||||
s.close() // shutdown mock npm server.
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
38
node_modules/npm/test/tap/404-private-registry-scoped.js
generated
vendored
Normal file
38
node_modules/npm/test/tap/404-private-registry-scoped.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap.js')
|
||||
var mr = require('npm-registry-mock')
|
||||
var server
|
||||
|
||||
test('setup', function (t) {
|
||||
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('scoped package names not mangled on error with non-root registry', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'cache',
|
||||
'add',
|
||||
'@scope/foo@*',
|
||||
'--force'
|
||||
],
|
||||
{},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'correctly handled 404')
|
||||
t.equal(code, 1, 'exited with error')
|
||||
t.match(stderr, /404 Not found/, 'should notify the sort of error as a 404')
|
||||
t.match(stderr, /@scope\/foo/, 'should have package name in error')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
t.pass('cleaned up')
|
||||
server.done()
|
||||
server.close()
|
||||
t.end()
|
||||
})
|
39
node_modules/npm/test/tap/404-private-registry.js
generated
vendored
Normal file
39
node_modules/npm/test/tap/404-private-registry.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
var test = require('tap').test
|
||||
var path = require('path')
|
||||
var common = require('../common-tap.js')
|
||||
var mr = require('npm-registry-mock')
|
||||
var server
|
||||
|
||||
var packageName = path.basename(__filename,'.js')
|
||||
|
||||
test('setup', function (t) {
|
||||
mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('package names not mangled on error with non-root registry', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'cache',
|
||||
'add',
|
||||
packageName + '@*'
|
||||
],
|
||||
{},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'correctly handled 404')
|
||||
t.equal(code, 1, 'exited with error')
|
||||
t.match(stderr, packageName, 'should have package name in error')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
t.pass('cleaned up')
|
||||
server.done()
|
||||
server.close()
|
||||
t.end()
|
||||
})
|
527
node_modules/npm/test/tap/access.js
generated
vendored
Normal file
527
node_modules/npm/test/tap/access.js
generated
vendored
Normal file
@@ -0,0 +1,527 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var mr = require('npm-registry-mock')
|
||||
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'access')
|
||||
var server
|
||||
|
||||
var scoped = {
|
||||
name: '@scoped/pkg',
|
||||
version: '1.1.1'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
mkdirp(pkg, function (er) {
|
||||
t.ifError(er, pkg + ' made successfully')
|
||||
|
||||
mr({port: common.port}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server = s
|
||||
|
||||
fs.writeFile(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(scoped),
|
||||
function (er) {
|
||||
t.ifError(er, 'wrote package.json')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('npm access public on current package', function (t) {
|
||||
server.post('/-/package/%40scoped%2Fpkg/access', JSON.stringify({
|
||||
access: 'public'
|
||||
})).reply(200, {
|
||||
accessChanged: true
|
||||
})
|
||||
common.npm([
|
||||
'access',
|
||||
'public',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {
|
||||
cwd: pkg
|
||||
},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm access public when no package passed and no package.json', function (t) {
|
||||
// need to simulate a missing package.json
|
||||
var missing = path.join(__dirname, 'access-public-missing-guard')
|
||||
mkdirp.sync(path.join(missing, 'node_modules'))
|
||||
|
||||
common.npm([
|
||||
'access',
|
||||
'public',
|
||||
'--registry', common.registry
|
||||
], {
|
||||
cwd: missing
|
||||
},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access')
|
||||
t.match(stderr, /no package name passed to command and no package.json found/)
|
||||
rimraf.sync(missing)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm access public when no package passed and invalid package.json', function (t) {
|
||||
// need to simulate a missing package.json
|
||||
var invalid = path.join(__dirname, 'access-public-invalid-package')
|
||||
mkdirp.sync(path.join(invalid, 'node_modules'))
|
||||
// it's hard to force `read-package-json` to break w/o ENOENT, but this will do it
|
||||
fs.writeFileSync(path.join(invalid, 'package.json'), '{\n')
|
||||
|
||||
common.npm([
|
||||
'access',
|
||||
'public',
|
||||
'--registry', common.registry
|
||||
], {
|
||||
cwd: invalid
|
||||
},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access')
|
||||
t.match(stderr, /Failed to parse json/)
|
||||
rimraf.sync(invalid)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm access restricted on current package', function (t) {
|
||||
server.post('/-/package/%40scoped%2Fpkg/access', JSON.stringify({
|
||||
access: 'restricted'
|
||||
})).reply(200, {
|
||||
accessChanged: true
|
||||
})
|
||||
common.npm([
|
||||
'access',
|
||||
'restricted',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {
|
||||
cwd: pkg
|
||||
},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm access on named package', function (t) {
|
||||
server.post('/-/package/%40scoped%2Fanother/access', {
|
||||
access: 'public'
|
||||
}).reply(200, {
|
||||
accessChaged: true
|
||||
})
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'public', '@scoped/another',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm change access on unscoped package', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'restricted', 'yargs',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ok(code, 'exited with Error')
|
||||
t.matches(
|
||||
stderr, /access commands are only accessible for scoped packages/)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access grant read-only', function (t) {
|
||||
server.put('/-/team/myorg/myteam/package', {
|
||||
permissions: 'read-only',
|
||||
package: '@scoped/another'
|
||||
}).reply(201, {
|
||||
accessChaged: true
|
||||
})
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'grant', 'read-only',
|
||||
'myorg:myteam',
|
||||
'@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access grant')
|
||||
t.equal(code, 0, 'exited with Error')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access grant read-write', function (t) {
|
||||
server.put('/-/team/myorg/myteam/package', {
|
||||
permissions: 'read-write',
|
||||
package: '@scoped/another'
|
||||
}).reply(201, {
|
||||
accessChaged: true
|
||||
})
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'grant', 'read-write',
|
||||
'myorg:myteam',
|
||||
'@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access grant')
|
||||
t.equal(code, 0, 'exited with Error')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access grant others', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'grant', 'rerere',
|
||||
'myorg:myteam',
|
||||
'@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ok(code, 'exited with Error')
|
||||
t.matches(stderr, /read-only/)
|
||||
t.matches(stderr, /read-write/)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access revoke', function (t) {
|
||||
server.delete('/-/team/myorg/myteam/package', {
|
||||
package: '@scoped/another'
|
||||
}).reply(200, {
|
||||
accessChaged: true
|
||||
})
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'revoke',
|
||||
'myorg:myteam',
|
||||
'@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access grant')
|
||||
t.equal(code, 0, 'exited with Error')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-packages with no team', function (t) {
|
||||
var serverPackages = {
|
||||
'@foo/bar': 'write',
|
||||
'@foo/util': 'read'
|
||||
}
|
||||
var clientPackages = {
|
||||
'@foo/bar': 'read-write',
|
||||
'@foo/util': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/org/username/package?format=cli'
|
||||
).reply(200, serverPackages)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-packages',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-packages')
|
||||
t.same(JSON.parse(stdout), clientPackages)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-packages on team', function (t) {
|
||||
var serverPackages = {
|
||||
'@foo/bar': 'write',
|
||||
'@foo/util': 'read'
|
||||
}
|
||||
var clientPackages = {
|
||||
'@foo/bar': 'read-write',
|
||||
'@foo/util': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/team/myorg/myteam/package?format=cli'
|
||||
).reply(200, serverPackages)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-packages',
|
||||
'myorg:myteam',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-packages')
|
||||
t.same(JSON.parse(stdout), clientPackages)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-packages on org', function (t) {
|
||||
var serverPackages = {
|
||||
'@foo/bar': 'write',
|
||||
'@foo/util': 'read'
|
||||
}
|
||||
var clientPackages = {
|
||||
'@foo/bar': 'read-write',
|
||||
'@foo/util': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/org/myorg/package?format=cli'
|
||||
).reply(200, serverPackages)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-packages',
|
||||
'myorg',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-packages')
|
||||
t.same(JSON.parse(stdout), clientPackages)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-packages on user', function (t) {
|
||||
var serverPackages = {
|
||||
'@foo/bar': 'write',
|
||||
'@foo/util': 'read'
|
||||
}
|
||||
var clientPackages = {
|
||||
'@foo/bar': 'read-write',
|
||||
'@foo/util': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/org/myorg/package?format=cli'
|
||||
).reply(404, {error: 'nope'})
|
||||
server.get(
|
||||
'/-/user/myorg/package?format=cli'
|
||||
).reply(200, serverPackages)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-packages',
|
||||
'myorg',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-packages')
|
||||
t.same(JSON.parse(stdout), clientPackages)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-packages with no package specified or package.json', function (t) {
|
||||
// need to simulate a missing package.json
|
||||
var missing = path.join(__dirname, 'access-missing-guard')
|
||||
mkdirp.sync(path.join(missing, 'node_modules'))
|
||||
|
||||
var serverPackages = {
|
||||
'@foo/bar': 'write',
|
||||
'@foo/util': 'read'
|
||||
}
|
||||
var clientPackages = {
|
||||
'@foo/bar': 'read-write',
|
||||
'@foo/util': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/org/myorg/package?format=cli'
|
||||
).reply(404, {error: 'nope'})
|
||||
server.get(
|
||||
'/-/user/myorg/package?format=cli'
|
||||
).reply(200, serverPackages)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-packages',
|
||||
'myorg',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: missing },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-packages')
|
||||
t.same(JSON.parse(stdout), clientPackages)
|
||||
rimraf.sync(missing)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-collaborators on current', function (t) {
|
||||
var serverCollaborators = {
|
||||
'myorg:myteam': 'write',
|
||||
'myorg:anotherteam': 'read'
|
||||
}
|
||||
var clientCollaborators = {
|
||||
'myorg:myteam': 'read-write',
|
||||
'myorg:anotherteam': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/package/%40scoped%2Fpkg/collaborators?format=cli'
|
||||
).reply(200, serverCollaborators)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-collaborators',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-collaborators')
|
||||
t.same(JSON.parse(stdout), clientCollaborators)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-collaborators on package', function (t) {
|
||||
var serverCollaborators = {
|
||||
'myorg:myteam': 'write',
|
||||
'myorg:anotherteam': 'read'
|
||||
}
|
||||
var clientCollaborators = {
|
||||
'myorg:myteam': 'read-write',
|
||||
'myorg:anotherteam': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/package/%40scoped%2Fanother/collaborators?format=cli'
|
||||
).reply(200, serverCollaborators)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-collaborators',
|
||||
'@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-collaborators')
|
||||
t.same(JSON.parse(stdout), clientCollaborators)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access ls-collaborators on current w/user filter', function (t) {
|
||||
var serverCollaborators = {
|
||||
'myorg:myteam': 'write',
|
||||
'myorg:anotherteam': 'read'
|
||||
}
|
||||
var clientCollaborators = {
|
||||
'myorg:myteam': 'read-write',
|
||||
'myorg:anotherteam': 'read-only'
|
||||
}
|
||||
server.get(
|
||||
'/-/package/%40scoped%2Fanother/collaborators?format=cli&user=zkat'
|
||||
).reply(200, serverCollaborators)
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'ls-collaborators',
|
||||
'@scoped/another',
|
||||
'zkat',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm access ls-collaborators')
|
||||
t.same(JSON.parse(stdout), clientCollaborators)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access edit', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'edit', '@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ok(code, 'exited with Error')
|
||||
t.match(stderr, /edit subcommand is not implemented yet/)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('npm access blerg', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'access',
|
||||
'blerg', '@scoped/another',
|
||||
'--registry', common.registry
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ok(code, 'exited with Error')
|
||||
t.matches(stderr, /Usage:/)
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
t.pass('cleaned up')
|
||||
rimraf.sync(pkg)
|
||||
server.done()
|
||||
server.close()
|
||||
t.end()
|
||||
})
|
137
node_modules/npm/test/tap/add-local.js
generated
vendored
Normal file
137
node_modules/npm/test/tap/add-local.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
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, fancy, 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, fancy, 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)
|
||||
}
|
113
node_modules/npm/test/tap/add-named-update-protocol-port.js
generated
vendored
Normal file
113
node_modules/npm/test/tap/add-named-update-protocol-port.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
'use strict'
|
||||
var path = require('path')
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap')
|
||||
var mr = require('npm-registry-mock')
|
||||
var server1
|
||||
var server2
|
||||
|
||||
var packageName = path.basename(__filename, '.js')
|
||||
|
||||
var fooPkg = {
|
||||
name: packageName,
|
||||
versions: {
|
||||
'0.0.0': {
|
||||
name: packageName,
|
||||
version: '0.0.0',
|
||||
dist: {
|
||||
tarball: 'https://localhost:1338/registry/' + packageName + '/-/' + packageName + '-0.0.0.tgz',
|
||||
shasum: '356a192b7913b04c54574d18c28d46e6395428ab'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var iPackageName = packageName + 'i'
|
||||
var fooiPkg = {
|
||||
name: iPackageName,
|
||||
versions: {
|
||||
'0.0.0': {
|
||||
name: iPackageName,
|
||||
version: '0.0.0',
|
||||
dist: {
|
||||
tarball: 'http://127.0.0.1:1338/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz',
|
||||
shasum: '356a192b7913b04c54574d18c28d46e6395428ab'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
mr({
|
||||
port: 1337,
|
||||
throwOnUnmatched: true
|
||||
}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server1 = s
|
||||
mr({
|
||||
port: 1338,
|
||||
throwOnUnmatched: true
|
||||
}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server2 = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
test('tarball paths should update port if updating protocol', function (t) {
|
||||
server1.get('/registry/' + packageName).reply(200, fooPkg)
|
||||
server1.get(
|
||||
'/registry/' + packageName + '/-/' + packageName + '-0.0.0.tgz'
|
||||
).reply(200, '1')
|
||||
|
||||
common.npm(
|
||||
[
|
||||
'cache',
|
||||
'add',
|
||||
packageName + '@0.0.0',
|
||||
'--registry',
|
||||
'http://localhost:1337/registry'
|
||||
],
|
||||
{},
|
||||
function (er, code, stdout, stderr) {
|
||||
if (er) { throw er }
|
||||
t.equal(code, 0, 'addNamed worked')
|
||||
server1.done()
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('tarball paths should NOT update if different hostname', function (t) {
|
||||
server1.get('/registry/' + iPackageName).reply(200, fooiPkg)
|
||||
server2.get(
|
||||
'/registry/' + iPackageName + '/-/' + iPackageName + '-0.0.0.tgz'
|
||||
).reply(200, '1')
|
||||
|
||||
common.npm(
|
||||
[
|
||||
'cache',
|
||||
'add',
|
||||
iPackageName + '@0.0.0',
|
||||
'--registry',
|
||||
'http://localhost:1337/registry'
|
||||
],
|
||||
{},
|
||||
function (er, code, stdout, stderr) {
|
||||
if (er) { throw er }
|
||||
t.equal(code, 0, 'addNamed worked')
|
||||
server1.done()
|
||||
server2.done()
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
t.pass('cleaned up')
|
||||
server1.close()
|
||||
server2.close()
|
||||
t.end()
|
||||
})
|
133
node_modules/npm/test/tap/add-remote-git-fake-windows.js
generated
vendored
Normal file
133
node_modules/npm/test/tap/add-remote-git-fake-windows.js
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
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)
|
||||
}
|
78
node_modules/npm/test/tap/add-remote-git-file.js
generated
vendored
Normal file
78
node_modules/npm/test/tap/add-remote-git-file.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
var fs = require('fs')
|
||||
var resolve = require('path').resolve
|
||||
var url = require('url')
|
||||
|
||||
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-file')
|
||||
var repo = resolve(__dirname, 'add-remote-git-file-repo')
|
||||
|
||||
var git
|
||||
var cloneURL = 'git+file://' + resolve(pkg, 'child.git')
|
||||
|
||||
var pjChild = JSON.stringify({
|
||||
name: 'child',
|
||||
version: '1.0.3'
|
||||
}, null, 2) + '\n'
|
||||
|
||||
test('setup', function (t) {
|
||||
bootstrap()
|
||||
setup(function (er, r) {
|
||||
t.ifError(er, 'git started up successfully')
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
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')
|
||||
t.equal(
|
||||
url.parse(data._resolved).protocol,
|
||||
'git+file:',
|
||||
'npm didn\'t go crazy adding git+git+git+git'
|
||||
)
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('clean', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
mkdirp.sync(repo)
|
||||
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
|
||||
npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
|
||||
git = require('../../lib/utils/git.js')
|
||||
|
||||
common.makeGitRepo({
|
||||
path: repo,
|
||||
commands: [git.chainableExec(
|
||||
['clone', '--bare', repo, 'child.git'],
|
||||
{ cwd: pkg, env: process.env }
|
||||
)]
|
||||
}, cb)
|
||||
})
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(repo)
|
||||
rimraf.sync(pkg)
|
||||
}
|
130
node_modules/npm/test/tap/add-remote-git-get-resolved.js
generated
vendored
Normal file
130
node_modules/npm/test/tap/add-remote-git-get-resolved.js
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
'use strict'
|
||||
var test = require('tap').test
|
||||
|
||||
var npm = require('../../lib/npm.js')
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var normalizeGitUrl = require('normalize-git-url')
|
||||
var getResolved = null
|
||||
|
||||
/**
|
||||
* Note: This is here because `normalizeGitUrl` is usually called
|
||||
* before getResolved is, and receives *that* URL.
|
||||
*/
|
||||
function tryGetResolved(uri, treeish) {
|
||||
return getResolved(normalizeGitUrl(uri).url, treeish)
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
var opts = {
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
getResolved = require('../../lib/cache/add-remote-git.js').getResolved
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('add-remote-git#get-resolved git: passthru', function (t) {
|
||||
verify('git:github.com/foo/repo')
|
||||
verify('git:github.com/foo/repo.git')
|
||||
verify('git://github.com/foo/repo#decadacefadabade')
|
||||
verify('git://github.com/foo/repo.git#decadacefadabade')
|
||||
|
||||
function verify (uri) {
|
||||
t.equal(
|
||||
tryGetResolved(uri, 'decadacefadabade'),
|
||||
'git://github.com/foo/repo.git#decadacefadabade',
|
||||
uri + ' normalized to canonical form git://github.com/foo/repo.git#decadacefadabade'
|
||||
)
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
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#master')
|
||||
verify('git+ssh://git@github.com/foo/repo#decadacefadabade')
|
||||
|
||||
function verify (uri) {
|
||||
t.equal(
|
||||
tryGetResolved(uri, 'decadacefadabade'),
|
||||
'git+ssh://git@github.com/foo/repo.git#decadacefadabade',
|
||||
uri + ' normalized to canonical form git+ssh://git@github.com/foo/repo.git#decadacefadabade'
|
||||
)
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('add-remote-git#get-resolved HTTPS', function (t) {
|
||||
verify('https://github.com/foo/repo')
|
||||
verify('https://github.com/foo/repo#master')
|
||||
verify('git+https://github.com/foo/repo.git#master')
|
||||
verify('git+https://github.com/foo/repo#decadacefadabade')
|
||||
// DEPRECATED
|
||||
// this is an invalid URL but we normalize it
|
||||
// anyway. Users shouldn't use this in the future. See note
|
||||
// below for how this affected non-hosted URLs.
|
||||
// See https://github.com/npm/npm/issues/8881
|
||||
verify('git+https://github.com:foo/repo.git#master')
|
||||
|
||||
function verify (uri) {
|
||||
t.equal(
|
||||
tryGetResolved(uri, 'decadacefadabade'),
|
||||
'git+https://github.com/foo/repo.git#decadacefadabade',
|
||||
uri + ' normalized to canonical form git+https://github.com/foo/repo.git#decadacefadabade'
|
||||
)
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('add-remote-git#get-resolved edge cases', function (t) {
|
||||
|
||||
t.equal(
|
||||
tryGetResolved('git+ssh://user@bananaboat.com:galbi/blah.git', 'decadacefadabade'),
|
||||
'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',
|
||||
'don\'t break non-hosted scp-style locations'
|
||||
)
|
||||
|
||||
// DEPRECATED
|
||||
// When we were normalizing all git URIs, git+https: was being
|
||||
// automatically converted to ssh:. Some users were relying
|
||||
// on this funky behavior, so after removing the aggressive
|
||||
// normalization from non-hosted URIs, we brought this back.
|
||||
// See https://github.com/npm/npm/issues/8881
|
||||
t.equal(
|
||||
tryGetResolved('git+https://bananaboat:galbi/blah', 'decadacefadabade'),
|
||||
'git+https://bananaboat/galbi/blah#decadacefadabade',
|
||||
'don\'t break non-hosted scp-style locations'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
tryGetResolved('git+ssh://git.bananaboat.net/foo', 'decadacefadabade'),
|
||||
'git+ssh://git.bananaboat.net/foo#decadacefadabade',
|
||||
'don\'t break non-hosted SSH URLs'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
tryGetResolved('git+ssh://git.bananaboat.net:/foo', 'decadacefadabade'),
|
||||
'git+ssh://git.bananaboat.net:/foo#decadacefadabade',
|
||||
'don\'t break non-hosted SSH URLs'
|
||||
)
|
||||
|
||||
t.equal(
|
||||
tryGetResolved('git://gitbub.com/foo/bar.git', 'decadacefadabade'),
|
||||
'git://gitbub.com/foo/bar.git#decadacefadabade',
|
||||
'don\'t break non-hosted git: URLs'
|
||||
)
|
||||
|
||||
t.end()
|
||||
})
|
161
node_modules/npm/test/tap/add-remote-git-shrinkwrap.js
generated
vendored
Normal file
161
node_modules/npm/test/tap/add-remote-git-shrinkwrap.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
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-shrinkwrap')
|
||||
var repo = resolve(__dirname, 'add-remote-git-shrinkwrap-repo')
|
||||
|
||||
var daemon
|
||||
var daemonPID
|
||||
var git
|
||||
|
||||
var pjParent = JSON.stringify({
|
||||
name: 'parent',
|
||||
version: '1.2.3',
|
||||
dependencies: {
|
||||
'child': 'git://localhost:1234/child.git#master'
|
||||
}
|
||||
}, 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) {
|
||||
t.ifError(er, 'git started up successfully')
|
||||
|
||||
if (!er) {
|
||||
daemon = r[r.length - 2]
|
||||
daemonPID = r[r.length - 1]
|
||||
}
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('install from repo', function (t) {
|
||||
process.chdir(pkg)
|
||||
npm.commands.install('.', [], function (er) {
|
||||
t.ifError(er, 'npm installed via git')
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('shrinkwrap gets correct _from and _resolved (#7121)', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'shrinkwrap',
|
||||
'--loglevel', 'silent'
|
||||
],
|
||||
{ cwd: pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm shrinkwrapped without errors')
|
||||
t.notOk(code, '`npm shrinkwrap` exited with 0')
|
||||
t.equal(stdout.trim(), 'wrote npm-shrinkwrap.json')
|
||||
t.notOk(stderr, '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 },
|
||||
function (er, stdout, stderr) {
|
||||
t.ifErr(er, 'git rev-list ran without error')
|
||||
t.notOk(stderr, 'no error output')
|
||||
var treeish = stdout.trim()
|
||||
|
||||
t.equal(
|
||||
shrinkwrap.dependencies.child.resolved,
|
||||
'git://localhost:1234/child.git#' + treeish,
|
||||
'npm shrinkwrapped resolved correctly'
|
||||
)
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('clean', function (t) {
|
||||
daemon.on('close', function () {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
process.kill(daemonPID)
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
mkdirp.sync(repo)
|
||||
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
|
||||
npm.load({ prefix: pkg, registry: common.registry, loglevel: 'silent' }, function () {
|
||||
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)
|
||||
}
|
120
node_modules/npm/test/tap/add-remote-git.js
generated
vendored
Normal file
120
node_modules/npm/test/tap/add-remote-git.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
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) {
|
||||
t.ifError(er, 'git started up successfully')
|
||||
|
||||
if (!er) {
|
||||
daemon = r[r.length - 2]
|
||||
daemonPID = r[r.length - 1]
|
||||
}
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('install from repo', function (t) {
|
||||
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 () {
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
mkdirp.sync(repo)
|
||||
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
|
||||
npm.load({ registry: common.registry, loglevel: 'silent' }, function () {
|
||||
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)
|
||||
}
|
264
node_modules/npm/test/tap/adduser-always-auth.js
generated
vendored
Normal file
264
node_modules/npm/test/tap/adduser-always-auth.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var rimraf = require("rimraf")
|
||||
var mr = require("npm-registry-mock")
|
||||
|
||||
var test = require("tap").test
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var opts = {cwd : __dirname}
|
||||
var outfile = path.resolve(__dirname, "_npmrc")
|
||||
var responses = {
|
||||
"Username" : "u\n",
|
||||
"Password" : "p\n",
|
||||
"Email" : "u@p.me\n"
|
||||
}
|
||||
|
||||
function verifyStdout (runner, successMessage, t) {
|
||||
var remaining = Object.keys(responses).length
|
||||
return function (chunk) {
|
||||
if (remaining > 0) {
|
||||
remaining--
|
||||
|
||||
var label = chunk.toString('utf8').split(':')[0]
|
||||
runner.stdin.write(responses[label])
|
||||
|
||||
if (remaining === 0) runner.stdin.end()
|
||||
} else {
|
||||
var message = chunk.toString('utf8').trim()
|
||||
t.equal(message, successMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mocks (server) {
|
||||
server.filteringRequestBody(function (r) {
|
||||
if (r.match(/\"_id\":\"org\.couchdb\.user:u\"/)) {
|
||||
return "auth"
|
||||
}
|
||||
})
|
||||
server.put("/-/user/org.couchdb.user:u", "auth")
|
||||
.reply(201, {username : "u", password : "p", email : "u@p.me"})
|
||||
}
|
||||
|
||||
test("npm login", function (t) {
|
||||
mr({port : common.port, plugin : mocks}, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
"login",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent",
|
||||
"--userconfig", outfile
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(err, "no error output")
|
||||
var config = fs.readFileSync(outfile, "utf8")
|
||||
t.like(config, /:always-auth=false/, "always-auth is scoped and false (by default)")
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, "removed config file OK")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u on ' + common.registry + '/.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
|
||||
test('npm login --scope <scope> uses <scope>:registry as its URI', function (t) {
|
||||
var port = common.port + 1
|
||||
var uri = 'http://localhost:' + port + '/'
|
||||
var scope = '@myco'
|
||||
common.npm(
|
||||
[
|
||||
'config',
|
||||
'--userconfig', outfile,
|
||||
'set',
|
||||
scope + ':registry',
|
||||
uri
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
|
||||
mr({ port: port, plugin: mocks }, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
'login',
|
||||
'--loglevel', 'silent',
|
||||
'--userconfig', outfile,
|
||||
'--scope', scope
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
var config = fs.readFileSync(outfile, 'utf8')
|
||||
t.like(config, new RegExp(scope + ':registry=' + uri), 'scope:registry is set')
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, 'removed config file OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u to scope ' + scope + ' on ' + uri + '.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('npm login --scope <scope> makes sure <scope> is prefixed by an @', function (t) {
|
||||
var port = common.port + 1
|
||||
var uri = 'http://localhost:' + port + '/'
|
||||
var scope = 'myco'
|
||||
var prefixedScope = '@' + scope
|
||||
common.npm(
|
||||
[
|
||||
'--userconfig', outfile,
|
||||
'config',
|
||||
'set',
|
||||
prefixedScope + ':registry',
|
||||
uri
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
|
||||
mr({ port: port, plugin: mocks }, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
'login',
|
||||
'--loglevel', 'silent',
|
||||
'--userconfig', outfile,
|
||||
'--scope', scope
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
var config = fs.readFileSync(outfile, 'utf8')
|
||||
t.like(config, new RegExp(prefixedScope + ':registry=' + uri), 'scope:registry is set')
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, 'removed config file OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u to scope ' + prefixedScope + ' on ' + uri + '.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('npm login --scope <scope> --registry <registry> uses <registry> as its URI', function (t) {
|
||||
var scope = '@myco'
|
||||
common.npm(
|
||||
[
|
||||
'--userconfig', outfile,
|
||||
'config',
|
||||
'set',
|
||||
scope + ':registry',
|
||||
'invalidurl'
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
|
||||
mr({ port: common.port, plugin: mocks }, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
'login',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent',
|
||||
'--userconfig', outfile,
|
||||
'--scope', scope
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(err, 'no error output')
|
||||
var config = fs.readFileSync(outfile, 'utf8')
|
||||
t.like(config, new RegExp(scope + ':registry=' + common.registry), 'scope:registry is set')
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, 'removed config file OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u to scope ' + scope + ' on ' + common.registry + '/.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm login --always-auth", function (t) {
|
||||
mr({port : common.port, plugin : mocks}, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
"login",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent",
|
||||
"--userconfig", outfile,
|
||||
"--always-auth"
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(err, "no error output")
|
||||
var config = fs.readFileSync(outfile, "utf8")
|
||||
t.like(config, /:always-auth=true/, "always-auth is scoped and true")
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, "removed config file OK")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u on ' + common.registry + '/.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
|
||||
test("npm login --no-always-auth", function (t) {
|
||||
mr({port : common.port, plugin : mocks}, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
"login",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent",
|
||||
"--userconfig", outfile,
|
||||
"--no-always-auth"
|
||||
],
|
||||
opts,
|
||||
function (err, code) {
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(err, "no error output")
|
||||
var config = fs.readFileSync(outfile, "utf8")
|
||||
t.like(config, /:always-auth=false/, "always-auth is scoped and false")
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, "removed config file OK")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var message = 'Logged in as u on ' + common.registry + '/.'
|
||||
runner.stdout.on('data', verifyStdout(runner, message, t))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
test("cleanup", function (t) {
|
||||
rimraf.sync(outfile)
|
||||
t.pass("cleaned up")
|
||||
t.end()
|
||||
})
|
97
node_modules/npm/test/tap/adduser-legacy-auth.js
generated
vendored
Normal file
97
node_modules/npm/test/tap/adduser-legacy-auth.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var mr = require('npm-registry-mock')
|
||||
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var opts = { cwd: __dirname }
|
||||
var pkg = path.resolve(__dirname, 'adduser-legacy-auth')
|
||||
var outfile = path.resolve(pkg, '_npmrc')
|
||||
|
||||
var contents = '_auth=' + new Buffer('u:x').toString('base64') + '\n' +
|
||||
'registry=https://nonexistent.lvh.me/registry\n' +
|
||||
'email=u@p.me\n'
|
||||
|
||||
var responses = {
|
||||
'Username': 'u\n',
|
||||
'Password': 'p\n',
|
||||
'Email': 'u@p.me\n'
|
||||
}
|
||||
|
||||
function mocks (server) {
|
||||
server.filteringRequestBody(function (r) {
|
||||
if (r.match(/"_id":"org\.couchdb\.user:u"/)) {
|
||||
return 'auth'
|
||||
}
|
||||
})
|
||||
server.put('/-/user/org.couchdb.user:u', 'auth')
|
||||
.reply(409, { error: 'user exists' })
|
||||
server.get('/-/user/org.couchdb.user:u?write=true')
|
||||
.reply(200, { _rev: '3-deadcafebabebeef' })
|
||||
server.put(
|
||||
'/-/user/org.couchdb.user:u/-rev/3-deadcafebabebeef',
|
||||
'auth',
|
||||
{ authorization: 'Basic dTpw' }
|
||||
).reply(201, { username: 'u', password: 'p', email: 'u@p.me' })
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
mkdirp(pkg, function (er) {
|
||||
t.ifError(er, pkg + ' made successfully')
|
||||
|
||||
fs.writeFile(outfile, contents, function (er) {
|
||||
t.ifError(er, 'wrote legacy config')
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('npm login', function (t) {
|
||||
mr({ port: common.port, plugin: mocks }, function (er, s) {
|
||||
var runner = common.npm(
|
||||
[
|
||||
'login',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent',
|
||||
'--userconfig', outfile
|
||||
],
|
||||
opts,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm ran without issue')
|
||||
t.notOk(code, 'exited OK')
|
||||
t.notOk(stderr, 'no error output')
|
||||
var config = fs.readFileSync(outfile, 'utf8')
|
||||
t.like(config, /:always-auth=false/, 'always-auth is scoped and false (by default)')
|
||||
s.close()
|
||||
rimraf(outfile, function (err) {
|
||||
t.ifError(err, 'removed config file OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var remaining = Object.keys(responses).length
|
||||
runner.stdout.on('data', function (chunk) {
|
||||
if (remaining > 0) {
|
||||
remaining--
|
||||
|
||||
var label = chunk.toString('utf8').split(':')[0]
|
||||
runner.stdin.write(responses[label])
|
||||
|
||||
if (remaining === 0) runner.stdin.end()
|
||||
} else {
|
||||
var message = chunk.toString('utf8').trim()
|
||||
t.equal(message, 'Logged in as u on ' + common.registry + '/.')
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
rimraf.sync(pkg)
|
||||
t.pass('cleaned up')
|
||||
t.end()
|
||||
})
|
119
node_modules/npm/test/tap/bearer-token-check.js
generated
vendored
Normal file
119
node_modules/npm/test/tap/bearer-token-check.js
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
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 = {
|
||||
'name': '@scoped/underscore',
|
||||
'version': '1.3.1',
|
||||
'from': 'http://lvh.me:1337/scoped-underscore/-/scoped-underscore-1.3.1.tgz',
|
||||
'dependencies': {}
|
||||
}
|
||||
t.isDeeply(results[0], 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)
|
||||
}
|
17
node_modules/npm/test/tap/bin.js
generated
vendored
Normal file
17
node_modules/npm/test/tap/bin.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var path = require("path")
|
||||
var test = require("tap").test
|
||||
var common = require("../common-tap.js")
|
||||
var opts = { cwd: __dirname }
|
||||
var binDir = "../../node_modules/.bin"
|
||||
var fixture = path.resolve(__dirname, binDir)
|
||||
|
||||
test('npm bin', function (t) {
|
||||
common.npm(["bin"], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bin ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = path.resolve(stdout)
|
||||
t.equal(res, fixture + "\n")
|
||||
t.end()
|
||||
})
|
||||
})
|
83
node_modules/npm/test/tap/bitbucket-https-url-with-creds-package.js
generated
vendored
Normal file
83
node_modules/npm/test/tap/bitbucket-https-url-with-creds-package.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'bitbucket-https-url-with-creds-package')
|
||||
|
||||
var json = {
|
||||
name: 'bitbucket-https-url-with-creds-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private': 'git+https://user:pass@bitbucket.org/foo/private.git'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('bitbucket-https-url-with-creds-package', function (t) {
|
||||
var cloneUrls = [
|
||||
['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
|
||||
]
|
||||
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
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')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
80
node_modules/npm/test/tap/bitbucket-https-url-with-creds.js
generated
vendored
Normal file
80
node_modules/npm/test/tap/bitbucket-https-url-with-creds.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'bitbucket-https-url-with-creds')
|
||||
|
||||
var json = {
|
||||
name: 'bitbucket-https-url-with-creds',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('bitbucket-https-url-with-creds', function (t) {
|
||||
var cloneUrls = [
|
||||
['https://user:pass@bitbucket.org/foo/private.git', 'Bitbucket URLs with passwords try only that.']
|
||||
]
|
||||
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
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')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
84
node_modules/npm/test/tap/bitbucket-shortcut-package.js
generated
vendored
Normal file
84
node_modules/npm/test/tap/bitbucket-shortcut-package.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'bitbucket-shortcut-package')
|
||||
|
||||
var json = {
|
||||
name: 'bitbucket-shortcut-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private': 'bitbucket:foo/private'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('bitbucket-shortcut', function (t) {
|
||||
var cloneUrls = [
|
||||
['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'],
|
||||
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second']
|
||||
]
|
||||
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
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')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
81
node_modules/npm/test/tap/bitbucket-shortcut.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/bitbucket-shortcut.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'bitbucket-shortcut')
|
||||
|
||||
var json = {
|
||||
name: 'bitbucket-shortcut',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('bitbucket-shortcut', function (t) {
|
||||
var cloneUrls = [
|
||||
['git@bitbucket.org:foo/private.git', 'Bitbucket shortcuts try SSH first'],
|
||||
['https://bitbucket.org/foo/private.git', 'Bitbucket shortcuts try HTTPS URLs second']
|
||||
]
|
||||
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
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')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
151
node_modules/npm/test/tap/bugs.js
generated
vendored
Normal file
151
node_modules/npm/test/tap/bugs.js
generated
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
if (process.platform === "win32") {
|
||||
console.error("skipping test, because windows and shebangs")
|
||||
return
|
||||
}
|
||||
|
||||
var common = require("../common-tap.js")
|
||||
var mr = require("npm-registry-mock")
|
||||
|
||||
var test = require("tap").test
|
||||
var rimraf = require("rimraf")
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var join = path.join
|
||||
var outFile = path.join(__dirname, "/_output")
|
||||
|
||||
var opts = { cwd: __dirname }
|
||||
|
||||
test("setup", function (t) {
|
||||
var s = "#!/usr/bin/env bash\n" +
|
||||
"echo \"$@\" > " + JSON.stringify(__dirname) + "/_output\n"
|
||||
fs.writeFileSync(join(__dirname, "/_script.sh"), s, "ascii")
|
||||
fs.chmodSync(join(__dirname, "/_script.sh"), "0755")
|
||||
t.pass("made script")
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("npm bugs underscore", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "underscore",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://github.com/jashkenas/underscore/issues\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm bugs optimist - github (https://)", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "optimist",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://github.com/substack/node-optimist/issues\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm bugs npm-test-peer-deps - no repo", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "npm-test-peer-deps",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://www.npmjs.org/package/npm-test-peer-deps\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm bugs test-repo-url-http - non-github (http://)", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "test-repo-url-http",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://www.npmjs.org/package/test-repo-url-http\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm bugs test-repo-url-https - non-github (https://)", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "test-repo-url-https",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://www.npmjs.org/package/test-repo-url-https\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm bugs test-repo-url-ssh - non-github (ssh://)", function (t) {
|
||||
mr({port : common.port}, function (er, s) {
|
||||
common.npm([
|
||||
"bugs", "test-repo-url-ssh",
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=silent",
|
||||
"--browser=" + join(__dirname, "/_script.sh")
|
||||
], opts, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "bugs ran without issue")
|
||||
t.notOk(stderr, "should have no stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
var res = fs.readFileSync(outFile, "ascii")
|
||||
s.close()
|
||||
t.equal(res, "https://www.npmjs.org/package/test-repo-url-ssh\n")
|
||||
rimraf.sync(outFile)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
fs.unlinkSync(join(__dirname, "/_script.sh"))
|
||||
t.pass("cleaned up")
|
||||
t.end()
|
||||
})
|
81
node_modules/npm/test/tap/build-already-built.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/build-already-built.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
// if "npm rebuild" is run with bundled dependencies,
|
||||
// message "already built" should not be error
|
||||
var test = require("tap").test
|
||||
var path = require("path")
|
||||
var osenv = require("osenv")
|
||||
var rimraf = require("rimraf")
|
||||
var npmlog = require("npmlog")
|
||||
var mkdirp = require("mkdirp")
|
||||
var requireInject = require("require-inject")
|
||||
|
||||
var npm = require("../../lib/npm.js")
|
||||
|
||||
var PKG_DIR = path.resolve(__dirname, "build-already-built")
|
||||
var fakePkg = "foo"
|
||||
|
||||
test("setup", function (t) {
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("issue #6735 build 'already built' message", function (t) {
|
||||
npm.load({loglevel : "warn"}, function () {
|
||||
// capture log messages with level
|
||||
var log = ""
|
||||
npmlog.on("log", function (chunk) {
|
||||
log += chunk.level + " " + chunk.message + "\n"
|
||||
})
|
||||
|
||||
mkdirp.sync(fakePkg)
|
||||
var folder = path.resolve(fakePkg)
|
||||
|
||||
var global = npm.config.get("global")
|
||||
|
||||
var build = requireInject("../../lib/build", {
|
||||
})
|
||||
|
||||
t.test("pin previous behavior", function (t) {
|
||||
|
||||
build([fakePkg], global, false, false, function (err) {
|
||||
t.ok(err, "build failed as expected")
|
||||
t.similar(err.message, /package.json/, "missing package.json as expected")
|
||||
t.notSimilar(log, /already built/, "no already built message written")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test("simulate rebuild of bundledDependency", function (t) {
|
||||
|
||||
log = ""
|
||||
|
||||
build._didBuild[folder] = true
|
||||
|
||||
build([fakePkg], global, false, false, function (err) {
|
||||
t.ok(err, "build failed as expected")
|
||||
t.similar(err.message, /package.json/, "missing package.json as expected")
|
||||
|
||||
t.similar(log, /already built/, "already built message written")
|
||||
t.notSimilar(log, /ERR! already built/, "already built message written is not error")
|
||||
t.similar(log, /info already built/, "already built message written is info")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
test("cleanup", function (t) {
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(PKG_DIR)
|
||||
}
|
126
node_modules/npm/test/tap/builtin-config.js
generated
vendored
Normal file
126
node_modules/npm/test/tap/builtin-config.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
var fs = require("fs")
|
||||
|
||||
if (process.argv[2] === "write-builtin") {
|
||||
var pid = process.argv[3]
|
||||
fs.writeFileSync("npmrc", "foo=bar\npid=" + pid + "\n")
|
||||
return
|
||||
}
|
||||
|
||||
var rcdata = "foo=bar\npid=" + process.pid + "\n"
|
||||
var common = require("../common-tap.js")
|
||||
var path = require("path")
|
||||
var rimraf = require("rimraf")
|
||||
var mkdirp = require("mkdirp")
|
||||
var folder = path.resolve(__dirname, "builtin-config")
|
||||
var test = require("tap").test
|
||||
var npm = path.resolve(__dirname, "../..")
|
||||
var spawn = require("child_process").spawn
|
||||
var node = process.execPath
|
||||
|
||||
test("setup", function (t) {
|
||||
rimraf.sync(folder)
|
||||
mkdirp.sync(folder + "/first")
|
||||
mkdirp.sync(folder + "/second")
|
||||
mkdirp.sync(folder + "/cache")
|
||||
mkdirp.sync(folder + "/tmp")
|
||||
|
||||
t.pass("finished setup")
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
test("install npm into first folder", function (t) {
|
||||
var args = ["install", npm, "-g",
|
||||
"--prefix=" + folder + "/first",
|
||||
"--ignore-scripts",
|
||||
"--cache=" + folder + "/cache",
|
||||
"--no-spin",
|
||||
"--loglevel=silent",
|
||||
"--tmp=" + folder + "/tmp"]
|
||||
common.npm(args, {stdio: "inherit"}, function (er, code) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("write npmrc file", function (t) {
|
||||
common.npm(["explore", "npm", "-g",
|
||||
"--prefix=" + folder + "/first",
|
||||
"--cache=" + folder + "/cache",
|
||||
"--tmp=" + folder + "/tmp",
|
||||
"--no-spin",
|
||||
"--",
|
||||
node, __filename, "write-builtin", process.pid
|
||||
],
|
||||
{"stdio": "inherit"},
|
||||
function (er, code) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("use first npm to install second npm", function (t) {
|
||||
// get the root location
|
||||
common.npm([ "root", "-g",
|
||||
"--prefix=" + folder + "/first",
|
||||
"--cache=" + folder + "/cache",
|
||||
"--tmp=" + folder + "/tmp",
|
||||
"--no-spin"
|
||||
], {}, function (er, code, so) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0)
|
||||
var root = so.trim()
|
||||
t.ok(fs.statSync(root).isDirectory())
|
||||
|
||||
var bin = path.resolve(root, "npm/bin/npm-cli.js")
|
||||
spawn( node
|
||||
, [ bin
|
||||
, "install", npm
|
||||
, "-g"
|
||||
, "--prefix=" + folder + "/second"
|
||||
, "--cache=" + folder + "/cache"
|
||||
, "--tmp=" + folder + "/tmp"
|
||||
, "--no-spin"
|
||||
])
|
||||
.on("error", function (er) { throw er })
|
||||
.on("close", function (code) {
|
||||
t.equal(code, 0, "code is zero")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("verify that the builtin config matches", function (t) {
|
||||
common.npm([ "root", "-g",
|
||||
"--prefix=" + folder + "/first",
|
||||
"--cache=" + folder + "/cache",
|
||||
"--tmp=" + folder + "/tmp"
|
||||
], {}, function (er, code, so) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0)
|
||||
var firstRoot = so.trim()
|
||||
common.npm([ "root", "-g",
|
||||
"--prefix=" + folder + "/second",
|
||||
"--cache=" + folder + "/cache",
|
||||
"--tmp=" + folder + "/tmp"
|
||||
], {}, function (er, code, so) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0)
|
||||
var secondRoot = so.trim()
|
||||
var firstRc = path.resolve(firstRoot, "npm", "npmrc")
|
||||
var secondRc = path.resolve(secondRoot, "npm", "npmrc")
|
||||
var firstData = fs.readFileSync(firstRc, "utf8")
|
||||
var secondData = fs.readFileSync(secondRc, "utf8")
|
||||
t.equal(firstData, secondData)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
test("clean", function (t) {
|
||||
rimraf.sync(folder)
|
||||
t.end()
|
||||
})
|
77
node_modules/npm/test/tap/bundled-dependencies-nonarray.js
generated
vendored
Normal file
77
node_modules/npm/test/tap/bundled-dependencies-nonarray.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
|
||||
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 dir = path.resolve(__dirname, 'bundleddependencies')
|
||||
var pkg = path.resolve(dir, 'pkg-with-bundled')
|
||||
var dep = path.resolve(dir, 'a-bundled-dep')
|
||||
|
||||
var pj = JSON.stringify({
|
||||
name: 'pkg-with-bundled',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'a-bundled-dep': 'file:../a-bundled-dep'
|
||||
},
|
||||
bundledDependencies: {
|
||||
'a-bundled-dep': 'file:../a-bundled-dep'
|
||||
}
|
||||
}, null, 2) + '\n'
|
||||
|
||||
var pjDep = JSON.stringify({
|
||||
name: 'a-bundled-dep',
|
||||
version: '2.0.0'
|
||||
}, null, 2) + '\n'
|
||||
|
||||
test('setup', function (t) {
|
||||
bootstrap()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('errors on non-array bundleddependencies', function (t) {
|
||||
t.plan(6)
|
||||
process.chdir(pkg)
|
||||
npm.load({},
|
||||
function () {
|
||||
common.npm(['install'], { cwd: pkg }, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm install ran without issue')
|
||||
t.notOk(code, 'exited with a non-error code')
|
||||
t.notOk(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.ok(code, 'exited with a error code')
|
||||
t.ok(stderr.indexOf('be an array') > -1, 'nice error output')
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
mkdirp.sync(dir)
|
||||
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(path.resolve(pkg, 'package.json'), pj)
|
||||
|
||||
mkdirp.sync(dep)
|
||||
fs.writeFileSync(path.resolve(dep, 'package.json'), pjDep)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(dir)
|
||||
}
|
84
node_modules/npm/test/tap/cache-add-localdir-fallback.js
generated
vendored
Normal file
84
node_modules/npm/test/tap/cache-add-localdir-fallback.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
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")
|
||||
})
|
||||
})
|
||||
})
|
34
node_modules/npm/test/tap/cache-add-unpublished.js
generated
vendored
Normal file
34
node_modules/npm/test/tap/cache-add-unpublished.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var common = require("../common-tap.js")
|
||||
var test = require("tap").test
|
||||
var mr = require("npm-registry-mock")
|
||||
|
||||
test("cache add", function (t) {
|
||||
setup(function (er, s) {
|
||||
if (er) {
|
||||
throw er
|
||||
}
|
||||
common.npm([
|
||||
"cache",
|
||||
"add",
|
||||
"superfoo",
|
||||
"--registry=http://localhost:1337/"
|
||||
], {}, function (er, c, so, se) {
|
||||
if (er) throw er
|
||||
t.ok(c, "got non-zero exit code")
|
||||
t.equal(so, "", "nothing printed to stdout")
|
||||
t.similar(se, /404 Not Found: superfoo/, "got expected error")
|
||||
s.close()
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function setup (cb) {
|
||||
var s = require("http").createServer(function (req, res) {
|
||||
res.statusCode = 404
|
||||
res.end("{\"error\":\"not_found\"}\n")
|
||||
})
|
||||
s.listen(1337, function () {
|
||||
cb(null, s)
|
||||
})
|
||||
}
|
101
node_modules/npm/test/tap/cache-shasum-fork.js
generated
vendored
Normal file
101
node_modules/npm/test/tap/cache-shasum-fork.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
var fs = require('graceful-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')
|
||||
|
||||
// Install from a tarball that thinks it is underscore@1.5.1
|
||||
// (but is actually a fork)
|
||||
var forkPath = path.resolve(
|
||||
__dirname, '..', 'fixtures', 'forked-underscore-1.5.1.tgz'
|
||||
)
|
||||
var pkg = path.resolve(__dirname, 'cache-shasum-fork')
|
||||
var cache = path.join(pkg, 'cache')
|
||||
var server
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.comment('test for https://github.com/npm/npm/issues/3265')
|
||||
mr({ port: common.port }, function (er, s) {
|
||||
server = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm cache - install from fork', function (t) {
|
||||
setup()
|
||||
common.npm(
|
||||
[
|
||||
'--loglevel', 'silent',
|
||||
'--registry', common.registry,
|
||||
'install', forkPath
|
||||
],
|
||||
{
|
||||
cwd: pkg,
|
||||
env: { npm_config_cache: cache }
|
||||
},
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifErr(err, 'install finished without error')
|
||||
t.notOk(stderr, 'Should not get data on stderr: ' + stderr)
|
||||
t.equal(code, 0, 'install finished successfully')
|
||||
|
||||
t.equal(stdout, 'underscore@1.5.1 node_modules/underscore\n')
|
||||
var index = fs.readFileSync(
|
||||
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
|
||||
'utf8'
|
||||
)
|
||||
t.equal(index, 'console.log("This is the fork");\n\n')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
// Now install the real 1.5.1.
|
||||
test('npm cache - install from origin', function (t) {
|
||||
setup()
|
||||
common.npm(
|
||||
[
|
||||
'--loglevel', 'silent',
|
||||
'--registry', common.registry,
|
||||
'install', 'underscore'
|
||||
],
|
||||
{
|
||||
cwd: pkg,
|
||||
env: { npm_config_cache: cache }
|
||||
},
|
||||
function (err, code, stdout, stderr) {
|
||||
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, 'underscore@1.5.1 node_modules/underscore\n')
|
||||
var index = fs.readFileSync(
|
||||
path.join(pkg, 'node_modules', 'underscore', 'index.js'),
|
||||
'utf8'
|
||||
)
|
||||
t.equal(index, 'module.exports = require(\'./underscore\');\n')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
server.close()
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function setup () {
|
||||
mkdirp.sync(cache)
|
||||
mkdirp.sync(path.join(pkg, 'node_modules'))
|
||||
process.chdir(pkg)
|
||||
}
|
59
node_modules/npm/test/tap/cache-shasum.js
generated
vendored
Normal file
59
node_modules/npm/test/tap/cache-shasum.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
var npm = require.resolve("../../")
|
||||
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 spawn = require("child_process").spawn
|
||||
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) {
|
||||
var c = spawn(process.execPath, [
|
||||
npm, "cache", "add", "request@2.27.0",
|
||||
"--cache=" + cache,
|
||||
"--registry=" + common.registry,
|
||||
"--loglevel=quiet"
|
||||
])
|
||||
c.stderr.pipe(process.stderr)
|
||||
|
||||
c.stdout.on("data", function (d) {
|
||||
t.fail("Should not get data on stdout: " + d)
|
||||
})
|
||||
|
||||
c.on("close", function (code) {
|
||||
t.notOk(code, "exit ok")
|
||||
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.sync(cache)
|
||||
t.end()
|
||||
})
|
99
node_modules/npm/test/tap/circular-dep.js
generated
vendored
Normal file
99
node_modules/npm/test/tap/circular-dep.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var existsSync = fs.existsSync || path.existsSync
|
||||
|
||||
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.resolve(__dirname, 'circular-dep')
|
||||
var minimist = path.join(pkg, 'minimist')
|
||||
|
||||
var EXEC_OPTS = {
|
||||
cwd: path.join(pkg, 'minimist/node_modules'),
|
||||
npm_config_cache: path.join(pkg, 'cache')
|
||||
}
|
||||
|
||||
var json = {
|
||||
name: 'minimist',
|
||||
version: '0.0.5',
|
||||
dependencies: {
|
||||
optimist: '0.6.0'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
t.comment('test for https://github.com/npm/npm/issues/4312')
|
||||
setup(function () {
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('installing a package that depends on the current package', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent',
|
||||
'install', 'optimist'
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm ran without issue')
|
||||
t.notOk(code, 'npm ran without raising an error code')
|
||||
t.notOk(stderr, 'no error output')
|
||||
|
||||
common.npm(
|
||||
[
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent',
|
||||
'dedupe'
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm ran without issue')
|
||||
t.notOk(code, 'npm ran without raising an error code')
|
||||
t.notOk(stderr, 'no error output')
|
||||
|
||||
t.ok(existsSync(path.resolve(
|
||||
minimist,
|
||||
'node_modules', 'optimist',
|
||||
'node_modules', 'minimist'
|
||||
)), 'circular dependency uncircled')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
server.close()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup (cb) {
|
||||
cleanup()
|
||||
mkdirp.sync(minimist)
|
||||
fs.writeFileSync(
|
||||
path.join(minimist, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(path.resolve(pkg, 'minimist'))
|
||||
|
||||
fs.mkdirSync(path.resolve(pkg, 'minimist/node_modules'))
|
||||
mr({ port: common.port }, function (er, s) {
|
||||
server = s
|
||||
cb()
|
||||
})
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
66
node_modules/npm/test/tap/config-basic.js
generated
vendored
Normal file
66
node_modules/npm/test/tap/config-basic.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
var test = require("tap").test
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
var path = require("path")
|
||||
|
||||
var projectData = {
|
||||
"save-prefix": "~",
|
||||
"proprietary-attribs": false
|
||||
}
|
||||
|
||||
var ucData = common.ucData
|
||||
var envData = common.envData
|
||||
var envDataFix = common.envDataFix
|
||||
|
||||
var gcData = { "package-config:foo": "boo" }
|
||||
|
||||
var biData = {}
|
||||
|
||||
var cli = { foo: "bar", umask: 022 }
|
||||
|
||||
var expectList =
|
||||
[ cli,
|
||||
envDataFix,
|
||||
projectData,
|
||||
ucData,
|
||||
gcData,
|
||||
biData ]
|
||||
|
||||
var expectSources = {
|
||||
cli: { data: cli },
|
||||
env: {
|
||||
data: envDataFix,
|
||||
source: envData,
|
||||
prefix: ""
|
||||
},
|
||||
project: {
|
||||
path: path.resolve(__dirname, "..", "..", ".npmrc"),
|
||||
type: "ini",
|
||||
data: projectData
|
||||
},
|
||||
user: {
|
||||
path: common.userconfig,
|
||||
type: "ini",
|
||||
data: ucData
|
||||
},
|
||||
global: {
|
||||
path: common.globalconfig,
|
||||
type: "ini",
|
||||
data: gcData
|
||||
},
|
||||
builtin: { data: biData }
|
||||
}
|
||||
|
||||
test("no builtin", function (t) {
|
||||
npmconf.load(cli, function (er, conf) {
|
||||
if (er) throw er
|
||||
t.same(conf.list, expectList)
|
||||
t.same(conf.sources, expectSources)
|
||||
t.same(npmconf.rootConf.list, [])
|
||||
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.get("umask"), 022)
|
||||
t.equal(conf.get("heading"), "npm")
|
||||
t.end()
|
||||
})
|
||||
})
|
68
node_modules/npm/test/tap/config-builtin.js
generated
vendored
Normal file
68
node_modules/npm/test/tap/config-builtin.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
var test = require("tap").test
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
var path = require("path")
|
||||
|
||||
var ucData = common.ucData
|
||||
|
||||
var envData = common.envData
|
||||
var envDataFix = common.envDataFix
|
||||
|
||||
var gcData = { "package-config:foo": "boo" }
|
||||
|
||||
var biData = { "builtin-config": true }
|
||||
|
||||
var cli = { foo: "bar", heading: "foo", "git-tag-version": false }
|
||||
|
||||
var projectData = {
|
||||
"save-prefix": "~",
|
||||
"proprietary-attribs": false
|
||||
}
|
||||
|
||||
var expectList = [
|
||||
cli,
|
||||
envDataFix,
|
||||
projectData,
|
||||
ucData,
|
||||
gcData,
|
||||
biData
|
||||
]
|
||||
|
||||
var expectSources = {
|
||||
cli: { data: cli },
|
||||
env: {
|
||||
data: envDataFix,
|
||||
source: envData,
|
||||
prefix: ""
|
||||
},
|
||||
project: {
|
||||
path: path.resolve(__dirname, "..", "..", ".npmrc"),
|
||||
type: "ini",
|
||||
data: projectData
|
||||
},
|
||||
user: {
|
||||
path: common.userconfig,
|
||||
type: "ini",
|
||||
data: ucData
|
||||
},
|
||||
global: {
|
||||
path: common.globalconfig,
|
||||
type: "ini",
|
||||
data: gcData
|
||||
},
|
||||
builtin: { data: biData }
|
||||
}
|
||||
|
||||
test("with builtin", function (t) {
|
||||
npmconf.load(cli, common.builtin, function (er, conf) {
|
||||
if (er) throw er
|
||||
t.same(conf.list, expectList)
|
||||
t.same(conf.sources, expectSources)
|
||||
t.same(npmconf.rootConf.list, [])
|
||||
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.get("heading"), "foo")
|
||||
t.equal(conf.get("git-tag-version"), false)
|
||||
t.end()
|
||||
})
|
||||
})
|
18
node_modules/npm/test/tap/config-certfile.js
generated
vendored
Normal file
18
node_modules/npm/test/tap/config-certfile.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
require("./00-config-setup.js")
|
||||
|
||||
var path = require("path")
|
||||
var fs = require("fs")
|
||||
var test = require("tap").test
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
|
||||
test("cafile loads as ca", function (t) {
|
||||
var cafile = path.join(__dirname, "..", "fixtures", "config", "multi-ca")
|
||||
|
||||
npmconf.load({cafile: cafile}, function (er, conf) {
|
||||
if (er) throw er
|
||||
|
||||
t.same(conf.get("cafile"), cafile)
|
||||
t.same(conf.get("ca").join("\n"), fs.readFileSync(cafile, "utf8").trim())
|
||||
t.end()
|
||||
})
|
||||
})
|
350
node_modules/npm/test/tap/config-credentials.js
generated
vendored
Normal file
350
node_modules/npm/test/tap/config-credentials.js
generated
vendored
Normal file
@@ -0,0 +1,350 @@
|
||||
var test = require("tap").test
|
||||
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
|
||||
var URI = "https://registry.lvh.me:8661/"
|
||||
|
||||
test("getting scope with no credentials set", function (t) {
|
||||
npmconf.load({}, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var basic = conf.getCredentialsByURI(URI)
|
||||
t.equal(basic.scope, "//registry.lvh.me:8661/", "nerfed URL extracted")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("trying to set credentials with no URI", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI()
|
||||
}, "enforced missing URI")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("trying to clear credentials with no URI", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.throws(function () {
|
||||
conf.clearCredentialsByURI()
|
||||
}, "enforced missing URI")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with missing credentials object", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI(URI)
|
||||
}, "enforced missing credentials")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with empty credentials object", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI(URI, {})
|
||||
}, "enforced missing credentials")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with token", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.setCredentialsByURI(URI, {token : "simple-token"})
|
||||
}, "needs only token")
|
||||
|
||||
var expected = {
|
||||
scope: '//registry.lvh.me:8661/',
|
||||
token: 'simple-token',
|
||||
username: undefined,
|
||||
password: undefined,
|
||||
email: undefined,
|
||||
auth: undefined,
|
||||
alwaysAuth: false
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got bearer token and scope")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("clear with token", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.setCredentialsByURI(URI, {token : "simple-token"})
|
||||
}, "needs only token")
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.clearCredentialsByURI(URI)
|
||||
}, "needs only URI")
|
||||
|
||||
t.notOk(conf.getCredentialsByURI(URI).token, "token all gone")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with missing username", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
}, "enforced missing email")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with missing password", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
}, "enforced missing email")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with missing email", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password"
|
||||
}
|
||||
|
||||
t.throws(function () {
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
}, "enforced missing email")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with old-style credentials", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
}, "requires all of username, password, and email")
|
||||
|
||||
var expected = {
|
||||
scope : "//registry.lvh.me:8661/",
|
||||
token : undefined,
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : false
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("clear with old-style credentials", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
}, "requires all of username, password, and email")
|
||||
|
||||
t.doesNotThrow(function () {
|
||||
conf.clearCredentialsByURI(URI)
|
||||
}, "clearing only required URI")
|
||||
|
||||
t.notOk(conf.getCredentialsByURI(URI).username, "username cleared")
|
||||
t.notOk(conf.getCredentialsByURI(URI).password, "password cleared")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("get old-style credentials for default registry", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
var actual = conf.getCredentialsByURI(conf.get("registry"))
|
||||
var expected = {
|
||||
scope : "//registry.npmjs.org/",
|
||||
token : undefined,
|
||||
password : "password",
|
||||
username : "username",
|
||||
email : "i@izs.me",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : false
|
||||
}
|
||||
t.same(actual, expected)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with always-auth enabled", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
alwaysAuth : true
|
||||
}
|
||||
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
|
||||
var expected = {
|
||||
scope : "//registry.lvh.me:8661/",
|
||||
token : undefined,
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : true
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with always-auth disabled", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
alwaysAuth : false
|
||||
}
|
||||
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
|
||||
var expected = {
|
||||
scope : "//registry.lvh.me:8661/",
|
||||
token : undefined,
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : false
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with global always-auth enabled", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
var original = conf.get("always-auth")
|
||||
conf.set("always-auth", true)
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
|
||||
var expected = {
|
||||
scope : "//registry.lvh.me:8661/",
|
||||
token : undefined,
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : true
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
|
||||
|
||||
conf.set("always-auth", original)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("set with global always-auth disabled", function (t) {
|
||||
npmconf.load(common.builtin, function (er, conf) {
|
||||
t.ifError(er, "configuration loaded")
|
||||
var original = conf.get("always-auth")
|
||||
conf.set("always-auth", false)
|
||||
|
||||
var credentials = {
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net"
|
||||
}
|
||||
|
||||
conf.setCredentialsByURI(URI, credentials)
|
||||
|
||||
var expected = {
|
||||
scope : "//registry.lvh.me:8661/",
|
||||
token : undefined,
|
||||
username : "username",
|
||||
password : "password",
|
||||
email : "ogd@aoaioxxysz.net",
|
||||
auth : "dXNlcm5hbWU6cGFzc3dvcmQ=",
|
||||
alwaysAuth : false
|
||||
}
|
||||
|
||||
t.same(conf.getCredentialsByURI(URI), expected, "got credentials")
|
||||
|
||||
conf.set("always-auth", original)
|
||||
t.end()
|
||||
})
|
||||
})
|
72
node_modules/npm/test/tap/config-edit.js
generated
vendored
Normal file
72
node_modules/npm/test/tap/config-edit.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
|
||||
var mkdirp = require("mkdirp")
|
||||
var rimraf = require("rimraf")
|
||||
var test = require("tap").test
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var pkg = path.resolve(__dirname, "npm-global-edit")
|
||||
|
||||
var editorSrc = function () {/*
|
||||
#!/usr/bin/env node
|
||||
var fs = require("fs")
|
||||
if (fs.existsSync(process.argv[2])) {
|
||||
console.log("success")
|
||||
} else {
|
||||
console.log("error")
|
||||
process.exit(1)
|
||||
}
|
||||
*/}.toString().split("\n").slice(1, -1).join("\n")
|
||||
var editorPath = path.join(pkg, "editor")
|
||||
|
||||
test("setup", function (t) {
|
||||
cleanup(function (er) {
|
||||
t.ifError(er, "old directory removed")
|
||||
|
||||
mkdirp(pkg, "0777", function (er) {
|
||||
fs.writeFileSync(editorPath, editorSrc)
|
||||
fs.chmodSync(editorPath, "0777")
|
||||
t.ifError(er, "created package directory correctly")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("saving configs", function (t) {
|
||||
var opts = {
|
||||
cwd: pkg,
|
||||
env: {
|
||||
PATH: process.env.PATH,
|
||||
EDITOR: editorPath
|
||||
}
|
||||
}
|
||||
common.npm(
|
||||
[
|
||||
"config",
|
||||
"--prefix", pkg,
|
||||
"--global",
|
||||
"edit"
|
||||
],
|
||||
opts,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "command ran without issue")
|
||||
|
||||
t.equal(stderr, "", "got nothing on stderr")
|
||||
t.equal(code, 0, "exit ok")
|
||||
t.equal(stdout, "success\n", "got success message")
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
cleanup(function (er) {
|
||||
t.ifError(er, "test directory removed OK")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
function cleanup (cb) {
|
||||
rimraf(pkg, cb)
|
||||
}
|
14
node_modules/npm/test/tap/config-malformed.js
generated
vendored
Normal file
14
node_modules/npm/test/tap/config-malformed.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
var test = require('tap').test
|
||||
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
|
||||
test('with malformed', function (t) {
|
||||
npmconf.load({}, common.malformed, function (er, conf) {
|
||||
t.ok(er, 'Expected parse error')
|
||||
if (!(er && /Failed parsing JSON config key email/.test(er.message))) {
|
||||
throw er
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
})
|
128
node_modules/npm/test/tap/config-meta.js
generated
vendored
Normal file
128
node_modules/npm/test/tap/config-meta.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
// this is a weird meta test. It verifies that all the instances of
|
||||
// `npm.config.get(...)` are:
|
||||
// a) Simple strings, and not variables
|
||||
// b) Documented
|
||||
// c) Defined in the `npmconf` package.
|
||||
|
||||
var test = require("tap").test
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var root = path.resolve(__dirname, "..", "..")
|
||||
var lib = path.resolve(root, "lib")
|
||||
var nm = path.resolve(root, "node_modules")
|
||||
var doc = path.resolve(root, "doc/misc/npm-config.md")
|
||||
var FILES = []
|
||||
var CONFS = {}
|
||||
var DOC = {}
|
||||
|
||||
var exceptions = [
|
||||
path.resolve(lib, "adduser.js"),
|
||||
path.resolve(lib, "config.js"),
|
||||
path.resolve(lib, "publish.js"),
|
||||
path.resolve(lib, "utils", "lifecycle.js"),
|
||||
path.resolve(lib, "utils", "map-to-registry.js"),
|
||||
path.resolve(nm, "npm-registry-client", "lib", "publish.js"),
|
||||
path.resolve(nm, "npm-registry-client", "lib", "request.js")
|
||||
]
|
||||
|
||||
test("get files", function (t) {
|
||||
walk(nm)
|
||||
walk(lib)
|
||||
t.pass("got files")
|
||||
t.end()
|
||||
|
||||
function walk(lib) {
|
||||
var files = fs.readdirSync(lib).map(function (f) {
|
||||
return path.resolve(lib, f)
|
||||
})
|
||||
files.forEach(function (f) {
|
||||
try {
|
||||
var s = fs.lstatSync(f)
|
||||
} catch (er) {
|
||||
return
|
||||
}
|
||||
if (s.isDirectory())
|
||||
walk(f)
|
||||
else if (f.match(/\.js$/))
|
||||
FILES.push(f)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
test("get lines", function (t) {
|
||||
FILES.forEach(function (f) {
|
||||
var lines = fs.readFileSync(f, "utf8").split(/\r|\n/)
|
||||
lines.forEach(function (l, i) {
|
||||
var matches = l.split(/conf(?:ig)?\.get\(/g)
|
||||
matches.shift()
|
||||
matches.forEach(function (m) {
|
||||
m = m.split(")").shift()
|
||||
var literal = m.match(/^['"].+?['"]/)
|
||||
if (literal) {
|
||||
m = literal[0].slice(1, -1)
|
||||
if (!m.match(/^\_/) && m !== "argv")
|
||||
CONFS[m] = {
|
||||
file: f,
|
||||
line: i
|
||||
}
|
||||
} else if (exceptions.indexOf(f) === -1) {
|
||||
t.fail("non-string-literal config used in " + f + ":" + i)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
t.pass("got lines")
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("get docs", function (t) {
|
||||
var d = fs.readFileSync(doc, "utf8").split(/\r|\n/)
|
||||
// walk down until the "## Config Settings" section
|
||||
for (var i = 0; i < d.length && d[i] !== "## Config Settings"; i++);
|
||||
i++
|
||||
// now gather up all the ^###\s lines until the next ^##\s
|
||||
for (; i < d.length && !d[i].match(/^## /); i++) {
|
||||
if (d[i].match(/^### /))
|
||||
DOC[ d[i].replace(/^### /, "").trim() ] = true
|
||||
}
|
||||
t.pass("read the docs")
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("check configs", function (t) {
|
||||
var defs = require("../../lib/config/defaults.js")
|
||||
var types = Object.keys(defs.types)
|
||||
var defaults = Object.keys(defs.defaults)
|
||||
for (var c1 in CONFS) {
|
||||
if (CONFS[c1].file.indexOf(lib) === 0) {
|
||||
t.ok(DOC[c1], "should be documented " + c1 + " "
|
||||
+ CONFS[c1].file + ":" + CONFS[c1].line)
|
||||
t.ok(types.indexOf(c1) !== -1, "should be defined in npmconf " + c1)
|
||||
t.ok(defaults.indexOf(c1) !== -1, "should have default in npmconf " + c1)
|
||||
}
|
||||
}
|
||||
|
||||
for (var c2 in DOC) {
|
||||
if (c2 !== "versions" && c2 !== "version" && c2 !== "init.version") {
|
||||
t.ok(CONFS[c2], "config in doc should be used somewhere " + c2)
|
||||
t.ok(types.indexOf(c2) !== -1, "should be defined in npmconf " + c2)
|
||||
t.ok(defaults.indexOf(c2) !== -1, "should have default in npmconf " + c2)
|
||||
}
|
||||
}
|
||||
|
||||
types.forEach(function (c) {
|
||||
if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
|
||||
t.ok(DOC[c], "defined type should be documented " + c)
|
||||
t.ok(CONFS[c], "defined type should be used " + c)
|
||||
}
|
||||
})
|
||||
|
||||
defaults.forEach(function (c) {
|
||||
if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
|
||||
t.ok(DOC[c], "defaulted type should be documented " + c)
|
||||
t.ok(CONFS[c], "defaulted type should be used " + c)
|
||||
}
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
56
node_modules/npm/test/tap/config-new-cafile.js
generated
vendored
Normal file
56
node_modules/npm/test/tap/config-new-cafile.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
require('./00-config-setup.js')
|
||||
|
||||
var path = require('path')
|
||||
var fs = require('graceful-fs')
|
||||
var test = require('tap').test
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var osenv = require('osenv')
|
||||
var npmconf = require('../../lib/config/core.js')
|
||||
|
||||
var dir = path.resolve(__dirname, 'config-new-cafile')
|
||||
var beep = path.resolve(dir, 'beep.pem')
|
||||
|
||||
test('setup', function (t) {
|
||||
bootstrap()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('can set new cafile when old is gone', function (t) {
|
||||
t.plan(5)
|
||||
npmconf.load(function (error, conf) {
|
||||
npmconf.loaded = false
|
||||
t.ifError(error)
|
||||
conf.set('cafile', beep, 'user')
|
||||
conf.save('user', function (error) {
|
||||
t.ifError(error)
|
||||
t.equal(conf.get('cafile'), beep)
|
||||
rimraf.sync(beep)
|
||||
npmconf.load(function (error, conf) {
|
||||
if (error) {
|
||||
throw error
|
||||
}
|
||||
t.equal(conf.get('cafile'), beep)
|
||||
conf.del('cafile')
|
||||
conf.save('user', function (error) {
|
||||
t.ifError(error)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
mkdirp.sync(dir)
|
||||
fs.writeFileSync(beep, '')
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(dir)
|
||||
}
|
81
node_modules/npm/test/tap/config-private.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/config-private.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
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-private")
|
||||
var opts = { cwd: pkg }
|
||||
|
||||
test("setup", function (t) {
|
||||
rimraf.sync(pkg)
|
||||
mkdirp.sync(pkg)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("config get private var (old auth)", function (t) {
|
||||
common.npm([
|
||||
"config",
|
||||
"get",
|
||||
"_auth"
|
||||
],
|
||||
opts,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err)
|
||||
|
||||
t.similar(stderr, /sekretz/, "password blocked on stderr")
|
||||
t.equal(stdout, "", "no output")
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("config get private var (new auth)", function (t) {
|
||||
common.npm([
|
||||
"config",
|
||||
"get",
|
||||
"//registry.npmjs.org/:_password"
|
||||
],
|
||||
opts,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err)
|
||||
|
||||
t.similar(stderr, /sekretz/, "password blocked on stderr")
|
||||
t.equal(stdout, "", "no output")
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("config get public var (new username)", function (t) {
|
||||
var FIXTURE_PATH = path.resolve(pkg, "fixture_npmrc")
|
||||
var s = "//registry.lvh.me/:username = wombat\n" +
|
||||
"//registry.lvh.me/:_password = YmFkIHBhc3N3b3Jk\n" +
|
||||
"//registry.lvh.me/:email = lindsay@wdu.org.au\n"
|
||||
fs.writeFileSync(FIXTURE_PATH, s, "ascii")
|
||||
fs.chmodSync(FIXTURE_PATH, "0444")
|
||||
|
||||
common.npm(
|
||||
[
|
||||
"config",
|
||||
"get",
|
||||
"//registry.lvh.me/:username",
|
||||
"--userconfig=" + FIXTURE_PATH,
|
||||
"--registry=http://registry.lvh.me/"
|
||||
],
|
||||
opts,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err)
|
||||
|
||||
t.equal(stderr, "", "stderr is empty")
|
||||
t.equal(stdout, "wombat\n", "got usename is output")
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("clean", function (t) {
|
||||
rimraf.sync(pkg)
|
||||
t.end()
|
||||
})
|
66
node_modules/npm/test/tap/config-project.js
generated
vendored
Normal file
66
node_modules/npm/test/tap/config-project.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
var test = require("tap").test
|
||||
var path = require("path")
|
||||
var fix = path.resolve(__dirname, "..", "fixtures", "config")
|
||||
var projectRc = path.resolve(fix, ".npmrc")
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
|
||||
var projectData = { just: "testing" }
|
||||
|
||||
var ucData = common.ucData
|
||||
var envData = common.envData
|
||||
var envDataFix = common.envDataFix
|
||||
|
||||
var gcData = { "package-config:foo": "boo" }
|
||||
|
||||
var biData = {}
|
||||
|
||||
var cli = { foo: "bar", umask: 022, prefix: fix }
|
||||
|
||||
var expectList = [
|
||||
cli,
|
||||
envDataFix,
|
||||
projectData,
|
||||
ucData,
|
||||
gcData,
|
||||
biData
|
||||
]
|
||||
|
||||
var expectSources = {
|
||||
cli: { data: cli },
|
||||
env: {
|
||||
data: envDataFix,
|
||||
source: envData,
|
||||
prefix: ""
|
||||
},
|
||||
project: {
|
||||
path: projectRc,
|
||||
type: "ini",
|
||||
data: projectData
|
||||
},
|
||||
user: {
|
||||
path: common.userconfig,
|
||||
type: "ini",
|
||||
data: ucData
|
||||
},
|
||||
global: {
|
||||
path: common.globalconfig,
|
||||
type: "ini",
|
||||
data: gcData
|
||||
},
|
||||
builtin: { data: biData }
|
||||
}
|
||||
|
||||
test("no builtin", function (t) {
|
||||
npmconf.load(cli, function (er, conf) {
|
||||
if (er) throw er
|
||||
t.same(conf.list, expectList)
|
||||
t.same(conf.sources, expectSources)
|
||||
t.same(npmconf.rootConf.list, [])
|
||||
t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.root, npmconf.defs.defaults)
|
||||
t.equal(conf.get("umask"), 022)
|
||||
t.equal(conf.get("heading"), "npm")
|
||||
t.end()
|
||||
})
|
||||
})
|
88
node_modules/npm/test/tap/config-save.js
generated
vendored
Normal file
88
node_modules/npm/test/tap/config-save.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
var fs = require("fs")
|
||||
var ini = require("ini")
|
||||
var test = require("tap").test
|
||||
var npmconf = require("../../lib/config/core.js")
|
||||
var common = require("./00-config-setup.js")
|
||||
|
||||
var expectConf = [
|
||||
"globalconfig = " + common.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",
|
||||
""
|
||||
].join("\n")
|
||||
|
||||
var expectFile = [
|
||||
"globalconfig = " + common.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",
|
||||
""
|
||||
].join("\n")
|
||||
|
||||
test("saving configs", function (t) {
|
||||
npmconf.load(function (er, conf) {
|
||||
if (er)
|
||||
throw er
|
||||
conf.set("sign-git-tag", false, "user")
|
||||
conf.del("nodedir")
|
||||
conf.del("tmp")
|
||||
var foundConf = ini.stringify(conf.sources.user.data)
|
||||
t.same(ini.parse(foundConf), ini.parse(expectConf))
|
||||
fs.unlinkSync(common.userconfig)
|
||||
conf.save("user", function (er) {
|
||||
if (er)
|
||||
throw er
|
||||
var uc = fs.readFileSync(conf.get("userconfig"), "utf8")
|
||||
t.same(ini.parse(uc), ini.parse(expectFile))
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("setting prefix", function (t) {
|
||||
npmconf.load(function (er, conf) {
|
||||
if (er)
|
||||
throw er
|
||||
|
||||
conf.prefix = "newvalue"
|
||||
t.same(conf.prefix, "newvalue")
|
||||
t.end()
|
||||
})
|
||||
})
|
163
node_modules/npm/test/tap/correct-mkdir.js
generated
vendored
Normal file
163
node_modules/npm/test/tap/correct-mkdir.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
var test = require('tap').test
|
||||
var assert = require('assert')
|
||||
var path = require('path')
|
||||
var requireInject = require('require-inject')
|
||||
var cache_dir = path.resolve(__dirname, 'correct-mkdir')
|
||||
|
||||
test('correct-mkdir: no race conditions', function (t) {
|
||||
var mock_fs = {}
|
||||
var did_hook = false
|
||||
mock_fs.stat = function (path, cb) {
|
||||
if (path === cache_dir) {
|
||||
// Return a non-matching owner
|
||||
cb(null, {
|
||||
uid: +process.uid + 1,
|
||||
isDirectory: function () {
|
||||
return true
|
||||
}
|
||||
})
|
||||
if (!did_hook) {
|
||||
did_hook = true
|
||||
doHook()
|
||||
}
|
||||
} else {
|
||||
assert.ok(false, 'Unhandled stat path: ' + path)
|
||||
}
|
||||
}
|
||||
var chown_in_progress = 0
|
||||
var mock_chownr = function (path, uid, gid, cb) {
|
||||
++chown_in_progress
|
||||
process.nextTick(function () {
|
||||
--chown_in_progress
|
||||
cb(null)
|
||||
})
|
||||
}
|
||||
var mocks = {
|
||||
'graceful-fs': mock_fs,
|
||||
'chownr': mock_chownr
|
||||
}
|
||||
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
|
||||
|
||||
var calls_in_progress = 3
|
||||
function handleCallFinish () {
|
||||
t.equal(chown_in_progress, 0, 'should not return while chown still in progress')
|
||||
if (!--calls_in_progress) {
|
||||
t.end()
|
||||
}
|
||||
}
|
||||
function doHook () {
|
||||
// This is fired during the first correctMkdir call, after the stat has finished
|
||||
// but before the chownr has finished
|
||||
// Buggy old code will fail and return a cached value before initial call is done
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
}
|
||||
// Initial call
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
// Immediate call again in case of race condition there
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
})
|
||||
|
||||
test('correct-mkdir: ignore ENOENTs from chownr', function (t) {
|
||||
var mock_fs = {}
|
||||
mock_fs.stat = function (path, cb) {
|
||||
if (path === cache_dir) {
|
||||
cb(null, {
|
||||
isDirectory: function () {
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
assert.ok(false, 'Unhandled stat path: ' + path)
|
||||
}
|
||||
}
|
||||
var mock_chownr = function (path, uid, gid, cb) {
|
||||
cb({code: 'ENOENT'})
|
||||
}
|
||||
var mocks = {
|
||||
'graceful-fs': mock_fs,
|
||||
'chownr': mock_chownr
|
||||
}
|
||||
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
|
||||
|
||||
function handleCallFinish (err) {
|
||||
t.ifErr(err, 'chownr\'s ENOENT errors were ignored')
|
||||
t.end()
|
||||
}
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
})
|
||||
|
||||
// NEED TO RUN LAST
|
||||
|
||||
// These test checks that Windows users are protected by crashes related to
|
||||
// unexpectedly having a UID/GID other than 0 if a user happens to add these
|
||||
// variables to their environment. There are assumptions in correct-mkdir
|
||||
// that special-case Windows by checking on UID-related things.
|
||||
test('correct-mkdir: SUDO_UID and SUDO_GID non-Windows', function (t) {
|
||||
process.env.SUDO_UID = 999
|
||||
process.env.SUDO_GID = 999
|
||||
process.getuid = function () { return 0 }
|
||||
process.getgid = function () { return 0 }
|
||||
var mock_fs = {}
|
||||
mock_fs.stat = function (path, cb) {
|
||||
if (path === cache_dir) {
|
||||
cb(null, {
|
||||
uid: 0,
|
||||
isDirectory: function () {
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
assert.ok(false, 'Unhandled stat path: ' + path)
|
||||
}
|
||||
}
|
||||
var mock_chownr = function (path, uid, gid, cb) {
|
||||
t.is(uid, +process.env.SUDO_UID, 'using the environment\'s UID')
|
||||
t.is(gid, +process.env.SUDO_GID, 'using the environment\'s GID')
|
||||
cb(null, {})
|
||||
}
|
||||
var mocks = {
|
||||
'graceful-fs': mock_fs,
|
||||
'chownr': mock_chownr
|
||||
}
|
||||
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
|
||||
|
||||
function handleCallFinish () {
|
||||
t.end()
|
||||
}
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
})
|
||||
|
||||
test('correct-mkdir: SUDO_UID and SUDO_GID Windows', function (t) {
|
||||
process.env.SUDO_UID = 999
|
||||
process.env.SUDO_GID = 999
|
||||
delete process.getuid
|
||||
delete process.getgid
|
||||
var mock_fs = {}
|
||||
mock_fs.stat = function (path, cb) {
|
||||
if (path === cache_dir) {
|
||||
cb(null, {
|
||||
uid: 0,
|
||||
isDirectory: function () {
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
assert.ok(false, 'Unhandled stat path: ' + path)
|
||||
}
|
||||
}
|
||||
var mock_chownr = function (path, uid, gid, cb) {
|
||||
t.fail('chownr should not be called at all on Windows')
|
||||
cb('nope')
|
||||
}
|
||||
var mocks = {
|
||||
'graceful-fs': mock_fs,
|
||||
'chownr': mock_chownr
|
||||
}
|
||||
var correctMkdir = requireInject('../../lib/utils/correct-mkdir.js', mocks)
|
||||
|
||||
function handleCallFinish (err) {
|
||||
t.ifErr(err, 'chownr was not called because Windows')
|
||||
t.end()
|
||||
}
|
||||
correctMkdir(cache_dir, handleCallFinish)
|
||||
})
|
147
node_modules/npm/test/tap/dedupe-scoped.js
generated
vendored
Normal file
147
node_modules/npm/test/tap/dedupe-scoped.js
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
var fs = require('fs')
|
||||
var join = require('path').join
|
||||
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var test = require('tap').test
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
var pkg = join(__dirname, 'dedupe-scoped')
|
||||
var modules = join(pkg, 'node_modules')
|
||||
|
||||
var EXEC_OPTS = { cwd: pkg }
|
||||
|
||||
var prolog = 'dedupe@0.0.0 ' + pkg
|
||||
var body = function () {/*
|
||||
├─┬ first@1.0.0
|
||||
│ └── @scope/shared@2.1.6
|
||||
└─┬ second@2.0.0
|
||||
└── @scope/shared@2.1.6
|
||||
*/}.toString().split('\n').slice(1, -1)
|
||||
|
||||
var deduper = {
|
||||
'name': 'dedupe',
|
||||
'version': '0.0.0',
|
||||
'dependencies': {
|
||||
'first': '1.0.0',
|
||||
'second': '2.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
var first = {
|
||||
'name': 'first',
|
||||
'version': '1.0.0',
|
||||
'dependencies': {
|
||||
'firstUnique': '0.6.0',
|
||||
'@scope/shared': '2.1.6'
|
||||
}
|
||||
}
|
||||
|
||||
var second = {
|
||||
'name': 'second',
|
||||
'version': '2.0.0',
|
||||
'dependencies': {
|
||||
'secondUnique': '1.2.0',
|
||||
'@scope/shared': '2.1.6'
|
||||
}
|
||||
}
|
||||
|
||||
var shared = {
|
||||
'name': '@scope/shared',
|
||||
'version': '2.1.6'
|
||||
}
|
||||
|
||||
var firstUnique = {
|
||||
'name': 'firstUnique',
|
||||
'version': '0.6.0'
|
||||
}
|
||||
|
||||
var secondUnique = {
|
||||
'name': 'secondUnique',
|
||||
'version': '1.2.0'
|
||||
}
|
||||
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
// we like the cars
|
||||
function ltrimm (l) { return l.trim() }
|
||||
|
||||
test('dedupe finds the common scoped modules and moves it up one level', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'find-dupes' // I actually found a use for this command!
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'successful dry run against fake install')
|
||||
t.notOk(code, 'npm ran without issue')
|
||||
t.notOk(stderr, 'npm printed no errors')
|
||||
t.same(
|
||||
stdout.trim().split('\n').map(ltrimm),
|
||||
[prolog].concat(body).map(ltrimm),
|
||||
'got expected output'
|
||||
)
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup (cb) {
|
||||
cleanup()
|
||||
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
join(pkg, 'package.json'),
|
||||
JSON.stringify(deduper, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'first'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'first', 'package.json'),
|
||||
JSON.stringify(first, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'first', 'node_modules', 'firstUnique'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'first', 'node_modules', 'firstUnique', 'package.json'),
|
||||
JSON.stringify(firstUnique, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'first', 'node_modules', '@scope', 'shared'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'first', 'node_modules', '@scope', 'shared', 'package.json'),
|
||||
JSON.stringify(shared, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'second'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'second', 'package.json'),
|
||||
JSON.stringify(second, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'second', 'node_modules', 'secondUnique'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'second', 'node_modules', 'secondUnique', 'package.json'),
|
||||
JSON.stringify(secondUnique, null, 2)
|
||||
)
|
||||
|
||||
mkdirp.sync(join(modules, 'second', 'node_modules', '@scope', 'shared'))
|
||||
fs.writeFileSync(
|
||||
join(modules, 'second', 'node_modules', '@scope', 'shared', 'package.json'),
|
||||
JSON.stringify(shared, null, 2)
|
||||
)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
}
|
86
node_modules/npm/test/tap/dedupe.js
generated
vendored
Normal file
86
node_modules/npm/test/tap/dedupe.js
generated
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var existsSync = fs.existsSync || path.existsSync
|
||||
|
||||
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 server
|
||||
|
||||
var pkg = path.join(__dirname, 'dedupe')
|
||||
|
||||
var EXEC_OPTS = { cwd: pkg }
|
||||
|
||||
var json = {
|
||||
author: 'Dedupe tester',
|
||||
name: 'dedupe',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
optimist: '0.6.0',
|
||||
clean: '2.1.6'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
t.comment('test for https://github.com/npm/npm/issues/4675')
|
||||
setup(function () {
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('dedupe finds the common module and moves it up one level', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'--registry', common.registry,
|
||||
'install', '.'
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code) {
|
||||
t.ifError(err, 'successfully installed directory')
|
||||
t.equal(code, 0, 'npm install exited with code')
|
||||
common.npm(
|
||||
[
|
||||
'dedupe'
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code) {
|
||||
t.ifError(err, 'successfully deduped against previous install')
|
||||
t.notOk(code, 'npm dedupe exited with code')
|
||||
|
||||
t.ok(existsSync(path.join(pkg, 'node_modules', 'minimist')))
|
||||
t.notOk(existsSync(path.join(pkg, 'node_modules', 'checker')))
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
server.close()
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
cleanup()
|
||||
mkdirp.sync(path.join(pkg, 'node_modules'))
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
|
||||
mr({ port: common.port }, function (er, s) {
|
||||
server = s
|
||||
cb()
|
||||
})
|
||||
}
|
163
node_modules/npm/test/tap/deprecate.js
generated
vendored
Normal file
163
node_modules/npm/test/tap/deprecate.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var mr = require('npm-registry-mock')
|
||||
var semver = require('semver')
|
||||
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'deprecate')
|
||||
var server
|
||||
|
||||
var cache = {
|
||||
'_id': 'cond',
|
||||
'_rev': '19-d458a706de1740662cd7728d7d7ddf07',
|
||||
'name': 'cond',
|
||||
'time': {
|
||||
'modified': '2015-02-13T07:33:58.120Z',
|
||||
'created': '2014-03-16T20:52:52.236Z',
|
||||
'0.0.0': '2014-03-16T20:52:52.236Z',
|
||||
'0.0.1': '2014-03-16T21:12:33.393Z',
|
||||
'0.0.2': '2014-03-16T21:15:25.430Z'
|
||||
},
|
||||
'versions': {
|
||||
'0.0.0': {},
|
||||
'0.0.1': {},
|
||||
'0.0.2': {}
|
||||
},
|
||||
'dist-tags': {
|
||||
'latest': '0.0.2'
|
||||
},
|
||||
'description': 'Restartable error handling system',
|
||||
'license': 'CC0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
mr({port: common.port}, function (err, s) {
|
||||
t.ifError(err, 'registry mocked successfully')
|
||||
server = s
|
||||
t.ok(true)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm deprecate an unscoped package', function (t) {
|
||||
var deprecated = JSON.parse(JSON.stringify(cache))
|
||||
deprecated.versions = {
|
||||
'0.0.0': {},
|
||||
'0.0.1': { deprecated: 'make it dead' },
|
||||
'0.0.2': {}
|
||||
}
|
||||
server.get('/cond?write=true').reply(200, cache)
|
||||
server.put('/cond', deprecated).reply(201, { deprecated: true })
|
||||
common.npm([
|
||||
'deprecate',
|
||||
'cond@0.0.1',
|
||||
'make it dead',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm deprecate')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm deprecate a scoped package', function (t) {
|
||||
var cacheCopy = JSON.parse(JSON.stringify(cache))
|
||||
cacheCopy.name = '@scope/cond'
|
||||
cacheCopy._id = '@scope/cond'
|
||||
var deprecated = JSON.parse(JSON.stringify(cacheCopy))
|
||||
deprecated.versions = {
|
||||
'0.0.0': {},
|
||||
'0.0.1': { deprecated: 'make it dead' },
|
||||
'0.0.2': {}
|
||||
}
|
||||
server.get('/@scope%2fcond?write=true').reply(200, cacheCopy)
|
||||
server.put('/@scope%2fcond', deprecated).reply(201, { deprecated: true })
|
||||
common.npm([
|
||||
'deprecate',
|
||||
'@scope/cond@0.0.1',
|
||||
'make it dead',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm deprecate')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm deprecate semver range', function (t) {
|
||||
var deprecated = JSON.parse(JSON.stringify(cache))
|
||||
deprecated.versions = {
|
||||
'0.0.0': { deprecated: 'make it dead' },
|
||||
'0.0.1': { deprecated: 'make it dead' },
|
||||
'0.0.2': {}
|
||||
}
|
||||
server.get('/cond?write=true').reply(200, cache)
|
||||
server.put('/cond', deprecated).reply(201, { deprecated: true })
|
||||
common.npm([
|
||||
'deprecate',
|
||||
'cond@<0.0.2',
|
||||
'make it dead',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm deprecate')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm deprecate bad semver range', function (t) {
|
||||
common.npm([
|
||||
'deprecate',
|
||||
'cond@-9001',
|
||||
'make it dead',
|
||||
'--registry', common.registry
|
||||
], {},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.equal(code, 1, 'errored')
|
||||
t.match(stderr, /invalid version range/, 'bad semver')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('npm deprecate a package with no semver range', function (t) {
|
||||
var deprecated = JSON.parse(JSON.stringify(cache))
|
||||
deprecated.versions = {
|
||||
'0.0.0': { deprecated: 'make it dead' },
|
||||
'0.0.1': { deprecated: 'make it dead' },
|
||||
'0.0.2': { deprecated: 'make it dead' }
|
||||
}
|
||||
server.get('/cond?write=true').reply(200, cache)
|
||||
server.put('/cond', deprecated).reply(201, { deprecated: true })
|
||||
common.npm([
|
||||
'deprecate',
|
||||
'cond',
|
||||
'make it dead',
|
||||
'--registry', common.registry,
|
||||
'--loglevel', 'silent'
|
||||
], {},
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, 'npm deprecate')
|
||||
t.equal(stderr, '', 'no error output')
|
||||
t.equal(code, 0, 'exited OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
server.close()
|
||||
t.ok(true)
|
||||
t.end()
|
||||
})
|
195
node_modules/npm/test/tap/dist-tag.js
generated
vendored
Normal file
195
node_modules/npm/test/tap/dist-tag.js
generated
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var mkdirp = require("mkdirp")
|
||||
var rimraf = require("rimraf")
|
||||
var mr = require("npm-registry-mock")
|
||||
|
||||
var test = require("tap").test
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var pkg = path.resolve(__dirname, "dist-tag")
|
||||
var server
|
||||
|
||||
var scoped = {
|
||||
name : "@scoped/pkg",
|
||||
version : "1.1.1"
|
||||
}
|
||||
|
||||
function mocks (server) {
|
||||
// ls current package
|
||||
server.get("/-/package/@scoped%2fpkg/dist-tags")
|
||||
.reply(200, { latest : "1.0.0", a : "0.0.1", b : "0.5.0" })
|
||||
|
||||
// ls named package
|
||||
server.get("/-/package/@scoped%2fanother/dist-tags")
|
||||
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0" })
|
||||
|
||||
// add c
|
||||
server.get("/-/package/@scoped%2fanother/dist-tags")
|
||||
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0" })
|
||||
server.put("/-/package/@scoped%2fanother/dist-tags/c", "\"7.7.7\"")
|
||||
.reply(200, { latest : "7.7.7", a : "0.0.2", b : "0.6.0", c : "7.7.7" })
|
||||
|
||||
// set same version
|
||||
server.get("/-/package/@scoped%2fanother/dist-tags")
|
||||
.reply(200, { latest : "2.0.0", b : "0.6.0" })
|
||||
|
||||
// rm
|
||||
server.get("/-/package/@scoped%2fanother/dist-tags")
|
||||
.reply(200, { latest : "2.0.0", a : "0.0.2", b : "0.6.0", c : "7.7.7" })
|
||||
server.delete("/-/package/@scoped%2fanother/dist-tags/c")
|
||||
.reply(200, { c : "7.7.7" })
|
||||
|
||||
// rm
|
||||
server.get("/-/package/@scoped%2fanother/dist-tags")
|
||||
.reply(200, { latest : "4.0.0" })
|
||||
}
|
||||
|
||||
test("setup", function (t) {
|
||||
mkdirp(pkg, function (er) {
|
||||
t.ifError(er, pkg + " made successfully")
|
||||
|
||||
mr({port : common.port, plugin : mocks}, function (er, s) {
|
||||
server = s
|
||||
|
||||
fs.writeFile(
|
||||
path.join(pkg, "package.json"),
|
||||
JSON.stringify(scoped),
|
||||
function (er) {
|
||||
t.ifError(er, "wrote package.json")
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("npm dist-tags ls in current package", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tags", "ls",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm access")
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(stderr, "no error output")
|
||||
t.equal(stdout, "a: 0.0.1\nb: 0.5.0\nlatest: 1.0.0\n")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("npm dist-tags ls on named package", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tags",
|
||||
"ls", "@scoped/another",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm access")
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(stderr, "no error output")
|
||||
t.equal(stdout, "a: 0.0.2\nb: 0.6.0\nlatest: 2.0.0\n")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("npm dist-tags add @scoped/another@7.7.7 c", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tags",
|
||||
"add", "@scoped/another@7.7.7", "c",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm access")
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(stderr, "no error output")
|
||||
t.equal(stdout, "+c: @scoped/another@7.7.7\n")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("npm dist-tags set same version", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tag",
|
||||
"set", "@scoped/another@0.6.0", "b",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "warn"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm access")
|
||||
t.notOk(code, "exited OK")
|
||||
t.equal(
|
||||
stderr,
|
||||
"npm WARN dist-tag add b is already set to version 0.6.0\n",
|
||||
"warned about setting same version"
|
||||
)
|
||||
t.notOk(stdout, "only expecting warning message")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("npm dist-tags rm @scoped/another c", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tags",
|
||||
"rm", "@scoped/another", "c",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm access")
|
||||
t.notOk(code, "exited OK")
|
||||
t.notOk(stderr, "no error output")
|
||||
t.equal(stdout, "-c: @scoped/another@7.7.7\n")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("npm dist-tags rm @scoped/another nonexistent", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"dist-tags",
|
||||
"rm", "@scoped/another", "nonexistent",
|
||||
"--registry", common.registry,
|
||||
"--loglevel", "silent"
|
||||
],
|
||||
{ cwd : pkg },
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "npm dist-tag")
|
||||
t.ok(code, "expecting nonzero exit code")
|
||||
t.notOk(stderr, "no error output")
|
||||
t.notOk(stdout, "not expecting output")
|
||||
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
t.pass("cleaned up")
|
||||
rimraf.sync(pkg)
|
||||
server.close()
|
||||
t.end()
|
||||
})
|
85
node_modules/npm/test/tap/false-name.js
generated
vendored
Normal file
85
node_modules/npm/test/tap/false-name.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
// this is a test for fix #2538
|
||||
|
||||
// the false_name-test-package has the name property 'test-package' set
|
||||
// in the package.json and a dependency named 'test-package' is also a
|
||||
// defined dependency of 'test-package-with-one-dep'.
|
||||
//
|
||||
// this leads to a conflict during installation and the fix is covered
|
||||
// by this test
|
||||
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
var existsSync = fs.existsSync || path.existsSync
|
||||
|
||||
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.join(__dirname, 'false-name')
|
||||
var cache = path.join(pkg, 'cache')
|
||||
var server
|
||||
|
||||
var EXEC_OPTS = { cwd: pkg }
|
||||
|
||||
var indexContent = 'module.exports = true\n'
|
||||
var json = {
|
||||
name: 'test-package',
|
||||
version: '0.0.0',
|
||||
main: 'index.js',
|
||||
dependencies: {
|
||||
'test-package-with-one-dep': '0.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
t.comment('test for https://github.com/npm/npm/issues/2538')
|
||||
setup()
|
||||
mr({ port: common.port }, function (er, s) {
|
||||
server = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('not every pkg.name can be required', function (t) {
|
||||
common.npm(
|
||||
[
|
||||
'install', '.',
|
||||
'--cache', cache,
|
||||
'--registry', common.registry
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code) {
|
||||
t.ifErr(err, 'install finished without error')
|
||||
t.equal(code, 0, 'install exited ok')
|
||||
t.ok(existsSync(path.join(
|
||||
pkg,
|
||||
'node_modules/test-package-with-one-dep',
|
||||
'node_modules/test-package'
|
||||
)), 'package installed OK')
|
||||
t.end()
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
server.close()
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(cache)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
fs.writeFileSync(path.join(pkg, 'index.js'), indexContent)
|
||||
}
|
558
node_modules/npm/test/tap/files-and-ignores.js
generated
vendored
Normal file
558
node_modules/npm/test/tap/files-and-ignores.js
generated
vendored
Normal file
@@ -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()
|
||||
}
|
||||
}
|
62
node_modules/npm/test/tap/gently-rm-overeager.js
generated
vendored
Normal file
62
node_modules/npm/test/tap/gently-rm-overeager.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
var resolve = require("path").resolve
|
||||
var fs = require("graceful-fs")
|
||||
var test = require("tap").test
|
||||
var mkdirp = require("mkdirp")
|
||||
var rimraf = require("rimraf")
|
||||
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var pkg = resolve(__dirname, "gently-rm-overeager")
|
||||
var dep = resolve(__dirname, "test-whoops")
|
||||
|
||||
var EXEC_OPTS = {
|
||||
cwd : pkg
|
||||
}
|
||||
|
||||
var fixture = {
|
||||
name: "@test/whoops",
|
||||
version: "1.0.0",
|
||||
scripts: {
|
||||
postinstall: "echo \"nope\" && exit 1"
|
||||
}
|
||||
}
|
||||
|
||||
test("setup", function (t) {
|
||||
cleanup()
|
||||
setup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("cache add", function (t) {
|
||||
common.npm(["install", "../test-whoops"], 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) {
|
||||
t.ifError(er, "package directory is still there")
|
||||
t.deepEqual(files, ["npm-debug.log"], "only debug log remains")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
rimraf.sync(dep)
|
||||
}
|
||||
|
||||
function setup () {
|
||||
mkdirp.sync(pkg)
|
||||
// so it doesn't try to install into npm's own node_modules
|
||||
mkdirp.sync(resolve(pkg, "node_modules"))
|
||||
mkdirp.sync(dep)
|
||||
fs.writeFileSync(resolve(dep, "package.json"), JSON.stringify(fixture))
|
||||
}
|
113
node_modules/npm/test/tap/gently-rm-symlink.js
generated
vendored
Normal file
113
node_modules/npm/test/tap/gently-rm-symlink.js
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
var resolve = require("path").resolve
|
||||
var fs = require("graceful-fs")
|
||||
var test = require("tap").test
|
||||
var mkdirp = require("mkdirp")
|
||||
var rimraf = require("rimraf")
|
||||
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var pkg = resolve(__dirname, "gently-rm-linked")
|
||||
var dep = resolve(__dirname, "test-linked")
|
||||
var glb = resolve(__dirname, "test-global")
|
||||
var lnk = resolve(__dirname, "test-global-link")
|
||||
|
||||
var EXEC_OPTS = {
|
||||
cwd : pkg
|
||||
}
|
||||
|
||||
|
||||
var index = "module.exports = function () { console.log('whoop whoop') }"
|
||||
|
||||
var fixture = {
|
||||
name: "@test/linked",
|
||||
version: "1.0.0",
|
||||
bin: {
|
||||
linked: "./index.js"
|
||||
}
|
||||
}
|
||||
|
||||
test("setup", function (t) {
|
||||
cleanup()
|
||||
setup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("install and link", function (t) {
|
||||
common.npm(
|
||||
[
|
||||
"--global",
|
||||
"--prefix", lnk,
|
||||
"--loglevel", "silent",
|
||||
"install", "../test-linked"
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "test-linked install didn't explode")
|
||||
t.notOk(code, "test-linked install also failed")
|
||||
t.notOk(stderr, "no log output")
|
||||
|
||||
verify(t, stdout)
|
||||
|
||||
// again, to make sure unlinking works properlyt
|
||||
common.npm(
|
||||
[
|
||||
"--global",
|
||||
"--prefix", lnk,
|
||||
"--loglevel", "silent",
|
||||
"install", "../test-linked"
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (er, code, stdout, stderr) {
|
||||
t.ifError(er, "test-linked install didn't explode")
|
||||
t.notOk(code, "test-linked install also failed")
|
||||
t.notOk(stderr, "no log output")
|
||||
|
||||
verify(t, stdout)
|
||||
|
||||
fs.readdir(pkg, function (er, files) {
|
||||
t.ifError(er, "package directory is still there")
|
||||
t.deepEqual(files, ["node_modules"], "only stub modules dir remains")
|
||||
|
||||
t.end()
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
function verify (t, stdout) {
|
||||
var binPath = resolve(lnk, "bin", "linked")
|
||||
var pkgPath = resolve(lnk, "lib", "node_modules", "@test", "linked")
|
||||
var trgPath = resolve(pkgPath, "index.js")
|
||||
t.equal(
|
||||
stdout,
|
||||
binPath+" -> "+trgPath+"\n@test/linked@1.0.0 "+pkgPath+"\n",
|
||||
"got expected install output"
|
||||
)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
rimraf.sync(dep)
|
||||
rimraf.sync(lnk)
|
||||
rimraf.sync(glb)
|
||||
}
|
||||
|
||||
function setup () {
|
||||
mkdirp.sync(pkg)
|
||||
mkdirp.sync(glb)
|
||||
fs.symlinkSync(glb, lnk)
|
||||
// so it doesn't try to install into npm's own node_modules
|
||||
mkdirp.sync(resolve(pkg, "node_modules"))
|
||||
mkdirp.sync(dep)
|
||||
fs.writeFileSync(resolve(dep, "package.json"), JSON.stringify(fixture))
|
||||
fs.writeFileSync(resolve(dep, "index.js"), index)
|
||||
}
|
126
node_modules/npm/test/tap/get.js
generated
vendored
Normal file
126
node_modules/npm/test/tap/get.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
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 () {}
|
||||
|
||||
var URI = "https://npm.registry:8043/rewrite"
|
||||
var TIMEOUT = 3600
|
||||
var FOLLOW = false
|
||||
var STALE_OK = true
|
||||
var TOKEN = "lolbutts"
|
||||
var AUTH = {
|
||||
token : TOKEN
|
||||
}
|
||||
var PARAMS = {
|
||||
timeout : TIMEOUT,
|
||||
follow : FOLLOW,
|
||||
staleOk : STALE_OK,
|
||||
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"
|
||||
}
|
||||
|
||||
// mock server reference
|
||||
var server
|
||||
|
||||
var mocks = {
|
||||
"get": {
|
||||
"/@bigco%2fsample/1.2.3" : [200, BIGCO_SAMPLE]
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
t.ifError(er)
|
||||
server = s
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("get call contract", function (t) {
|
||||
t.throws(function () {
|
||||
npm.registry.get(undefined, PARAMS, nop)
|
||||
}, "requires a URI")
|
||||
|
||||
t.throws(function () {
|
||||
npm.registry.get([], PARAMS, nop)
|
||||
}, "requires URI to be a string")
|
||||
|
||||
t.throws(function () {
|
||||
npm.registry.get(URI, undefined, nop)
|
||||
}, "requires params object")
|
||||
|
||||
t.throws(function () {
|
||||
npm.registry.get(URI, "", nop)
|
||||
}, "params must be object")
|
||||
|
||||
t.throws(function () {
|
||||
npm.registry.get(URI, PARAMS, undefined)
|
||||
}, "requires callback")
|
||||
|
||||
t.throws(function () {
|
||||
npm.registry.get(URI, PARAMS, "callback")
|
||||
}, "callback must be function")
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("basic request", function (t) {
|
||||
t.plan(9)
|
||||
|
||||
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")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
server.close()
|
||||
rimraf.sync(PKG_DIR)
|
||||
|
||||
t.end()
|
||||
})
|
84
node_modules/npm/test/tap/gist-short-shortcut-package.js
generated
vendored
Normal file
84
node_modules/npm/test/tap/gist-short-shortcut-package.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gist-short-shortcut-package')
|
||||
|
||||
var json = {
|
||||
name: 'gist-short-shortcut-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private-gist': 'gist:deadbeef'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
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']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install([], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
81
node_modules/npm/test/tap/gist-short-shortcut.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/gist-short-shortcut.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gist-short-shortcut')
|
||||
|
||||
var json = {
|
||||
name: 'gist-short-shortcut',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
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']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install(['gist:deadbeef'], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
84
node_modules/npm/test/tap/gist-shortcut-package.js
generated
vendored
Normal file
84
node_modules/npm/test/tap/gist-shortcut-package.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gist-shortcut-package')
|
||||
|
||||
var json = {
|
||||
name: 'gist-shortcut-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private-gist': 'gist:foo/deadbeef'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
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']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install([], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
81
node_modules/npm/test/tap/gist-shortcut.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/gist-shortcut.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gist-shortcut')
|
||||
|
||||
var json = {
|
||||
name: 'gist-shortcut',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
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']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install(['gist:foo/deadbeef'], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
46
node_modules/npm/test/tap/git-cache-locking.js
generated
vendored
Normal file
46
node_modules/npm/test/tap/git-cache-locking.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
var test = require('tap').test
|
||||
var common = require('../common-tap')
|
||||
var path = require('path')
|
||||
var rimraf = require('rimraf')
|
||||
var mkdirp = require('mkdirp')
|
||||
var pkg = path.resolve(__dirname, 'git-cache-locking')
|
||||
var tmp = path.join(pkg, 'tmp')
|
||||
var cache = path.join(pkg, 'cache')
|
||||
|
||||
test('setup', function (t) {
|
||||
rimraf.sync(pkg)
|
||||
mkdirp.sync(path.resolve(pkg, 'node_modules'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('git-cache-locking: install a git dependency', function (t) {
|
||||
// disable git integration tests on Travis.
|
||||
if (process.env.TRAVIS) return t.end()
|
||||
|
||||
// package c depends on a.git#master and b.git#master
|
||||
// package b depends on a.git#master
|
||||
common.npm([
|
||||
'install',
|
||||
'git://github.com/nigelzor/npm-4503-c.git'
|
||||
], {
|
||||
cwd: pkg,
|
||||
env: {
|
||||
npm_config_cache: cache,
|
||||
npm_config_tmp: tmp,
|
||||
npm_config_prefix: pkg,
|
||||
npm_config_global: 'false',
|
||||
HOME: process.env.HOME,
|
||||
Path: process.env.PATH,
|
||||
PATH: process.env.PATH
|
||||
}
|
||||
}, function (err, code, stdout, stderr) {
|
||||
t.ifErr(err, 'npm install finished without error')
|
||||
t.equal(0, code, 'npm install should succeed')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
rimraf.sync(pkg)
|
||||
t.end()
|
||||
})
|
63
node_modules/npm/test/tap/git-cache-no-hooks.js
generated
vendored
Normal file
63
node_modules/npm/test/tap/git-cache-no-hooks.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
var test = require("tap").test
|
||||
, fs = require("fs")
|
||||
, path = require("path")
|
||||
, rimraf = require("rimraf")
|
||||
, mkdirp = require("mkdirp")
|
||||
, spawn = require("child_process").spawn
|
||||
, npmCli = require.resolve("../../bin/npm-cli.js")
|
||||
, node = process.execPath
|
||||
, pkg = path.resolve(__dirname, "git-cache-no-hooks")
|
||||
, tmp = path.join(pkg, "tmp")
|
||||
, cache = path.join(pkg, "cache")
|
||||
|
||||
|
||||
test("setup", function (t) {
|
||||
rimraf.sync(pkg)
|
||||
mkdirp.sync(pkg)
|
||||
mkdirp.sync(cache)
|
||||
mkdirp.sync(tmp)
|
||||
mkdirp.sync(path.resolve(pkg, "node_modules"))
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("git-cache-no-hooks: install a git dependency", function (t) {
|
||||
|
||||
// disable git integration tests on Travis.
|
||||
if (process.env.TRAVIS) return t.end()
|
||||
|
||||
var command = [ npmCli
|
||||
, "install"
|
||||
, "git://github.com/nigelzor/npm-4503-a.git"
|
||||
]
|
||||
var child = spawn(node, command, {
|
||||
cwd: pkg,
|
||||
env: {
|
||||
"npm_config_cache" : cache,
|
||||
"npm_config_tmp" : tmp,
|
||||
"npm_config_prefix" : pkg,
|
||||
"npm_config_global" : "false",
|
||||
"npm_config_umask" : "00",
|
||||
HOME : process.env.HOME,
|
||||
Path : process.env.PATH,
|
||||
PATH : process.env.PATH
|
||||
},
|
||||
stdio: "inherit"
|
||||
})
|
||||
|
||||
child.on("close", function (code) {
|
||||
t.equal(code, 0, "npm install should succeed")
|
||||
|
||||
// verify permissions on git hooks
|
||||
var repoDir = "git-github-com-nigelzor-npm-4503-a-git-40c5cb24"
|
||||
var hooksPath = path.join(cache, "_git-remotes", repoDir, "hooks")
|
||||
fs.readdir(hooksPath, function (err) {
|
||||
t.equal(err && err.code, "ENOENT", "hooks are not brought along with repo")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
rimraf.sync(pkg)
|
||||
t.end()
|
||||
})
|
175
node_modules/npm/test/tap/git-dependency-install-link.js
generated
vendored
Normal file
175
node_modules/npm/test/tap/git-dependency-install-link.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
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 readJson = require('read-package-json')
|
||||
var mr = require('npm-registry-mock')
|
||||
|
||||
var npm = require('../../lib/npm.js')
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = resolve(__dirname, 'git-dependency-install-link')
|
||||
var repo = resolve(__dirname, 'git-dependency-install-link-repo')
|
||||
var cache = resolve(pkg, 'cache')
|
||||
|
||||
var daemon
|
||||
var daemonPID
|
||||
var git
|
||||
var mockRegistry
|
||||
|
||||
var EXEC_OPTS = {
|
||||
registry: common.registry,
|
||||
cwd: pkg,
|
||||
cache: cache
|
||||
}
|
||||
|
||||
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) {
|
||||
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 [no --link]', function (t) {
|
||||
process.chdir(pkg)
|
||||
|
||||
common.npm(['install', '--loglevel', 'error'], EXEC_OPTS, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm install failed')
|
||||
|
||||
t.dissimilar(stderr, /Command failed:/, 'expect git to succeed')
|
||||
t.dissimilar(stderr, /version not found/, 'should not go to repository')
|
||||
|
||||
readJson(resolve(pkg, 'node_modules', 'child', 'package.json'), function (err, data) {
|
||||
t.ifError(err, 'error reading child package.json')
|
||||
|
||||
t.equal(data && data.version, '1.0.3')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('install from git repo [with --link]', function (t) {
|
||||
process.chdir(pkg)
|
||||
rimraf.sync(resolve(pkg, 'node_modules'))
|
||||
|
||||
common.npm(['install', '--link', '--loglevel', 'error'], EXEC_OPTS, function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'npm install --link failed')
|
||||
|
||||
t.dissimilar(stderr, /Command failed:/, 'expect git to succeed')
|
||||
t.dissimilar(stderr, /version not found/, 'should not go to repository')
|
||||
|
||||
readJson(resolve(pkg, 'node_modules', 'child', 'package.json'), function (err, data) {
|
||||
t.ifError(err, 'error reading child package.json')
|
||||
|
||||
t.equal(data && data.version, '1.0.3')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('clean', function (t) {
|
||||
mockRegistry.close()
|
||||
daemon.on('close', function () {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
process.kill(daemonPID)
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
rimraf.sync(repo)
|
||||
rimraf.sync(pkg)
|
||||
mkdirp.sync(pkg)
|
||||
mkdirp.sync(cache)
|
||||
|
||||
fs.writeFileSync(resolve(pkg, 'package.json'), pjParent)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
mkdirp.sync(repo)
|
||||
fs.writeFileSync(resolve(repo, 'package.json'), pjChild)
|
||||
npm.load({
|
||||
link: true,
|
||||
prefix: pkg,
|
||||
loglevel: 'silent'
|
||||
}, function () {
|
||||
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)
|
||||
}
|
173
node_modules/npm/test/tap/git-npmignore.js
generated
vendored
Normal file
173
node_modules/npm/test/tap/git-npmignore.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
var cat = require("graceful-fs").writeFileSync
|
||||
var exec = require("child_process").exec
|
||||
var readdir = require("graceful-fs").readdirSync
|
||||
var resolve = require("path").resolve
|
||||
|
||||
var mkdirp = require("mkdirp")
|
||||
var rimraf = require("rimraf")
|
||||
var test = require("tap").test
|
||||
var tmpdir = require("osenv").tmpdir
|
||||
var which = require("which")
|
||||
|
||||
var common = require("../common-tap.js")
|
||||
|
||||
var pkg = resolve(__dirname, "git-npmignore")
|
||||
var dep = resolve(pkg, "deps", "gitch")
|
||||
var packname = "gitch-1.0.0.tgz"
|
||||
var packed = resolve(pkg, packname)
|
||||
var modules = resolve(pkg, "node_modules")
|
||||
var installed = resolve(modules, "gitch")
|
||||
var expected = [
|
||||
"a.js",
|
||||
"package.json",
|
||||
".npmignore"
|
||||
].sort()
|
||||
|
||||
var EXEC_OPTS = {
|
||||
cwd : pkg
|
||||
}
|
||||
|
||||
var gitignore = "node_modules/\n"
|
||||
var npmignore = "t.js\n"
|
||||
|
||||
var a = "console.log('hi');"
|
||||
var t = "require('tap').test(function (t) { t.pass('I am a test!'); t.end(); });"
|
||||
var fixture = {
|
||||
"name" : "gitch",
|
||||
"version" : "1.0.0",
|
||||
"private" : true,
|
||||
"main" : "a.js"
|
||||
}
|
||||
|
||||
|
||||
test("setup", function (t) {
|
||||
setup(function (er) {
|
||||
t.ifError(er, "setup ran OK")
|
||||
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("npm pack directly from directory", function (t) {
|
||||
packInstallTest(dep, t)
|
||||
})
|
||||
|
||||
test("npm pack via git", function (t) {
|
||||
packInstallTest("git+file://"+dep, t)
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
cleanup()
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
function packInstallTest (spec, t) {
|
||||
common.npm(
|
||||
[
|
||||
"--loglevel", "silent",
|
||||
"pack", spec
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "npm pack ran without error")
|
||||
t.notOk(code, "npm pack exited cleanly")
|
||||
t.notOk(stderr, "npm pack ran silently")
|
||||
t.equal(stdout.trim(), packname, "got expected package name")
|
||||
|
||||
common.npm(
|
||||
[
|
||||
"--loglevel", "silent",
|
||||
"install", packed
|
||||
],
|
||||
EXEC_OPTS,
|
||||
function (err, code, stdout, stderr) {
|
||||
t.ifError(err, "npm install ran without error")
|
||||
t.notOk(code, "npm install exited cleanly")
|
||||
t.notOk(stderr, "npm install ran silently")
|
||||
|
||||
var actual = readdir(installed).sort()
|
||||
t.same(actual, expected, "no unexpected files in packed directory")
|
||||
|
||||
rimraf(packed, function () {
|
||||
t.end()
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
cleanup()
|
||||
|
||||
mkdirp.sync(modules)
|
||||
mkdirp.sync(dep)
|
||||
|
||||
process.chdir(dep)
|
||||
|
||||
cat(resolve(dep, ".npmignore"), npmignore)
|
||||
cat(resolve(dep, ".gitignore"), gitignore)
|
||||
cat(resolve(dep, "a.js"), a)
|
||||
cat(resolve(dep, "t.js"), t)
|
||||
cat(resolve(dep, "package.json"), JSON.stringify(fixture))
|
||||
|
||||
common.npm(
|
||||
[
|
||||
"--loglevel", "silent",
|
||||
"cache", "clean"
|
||||
],
|
||||
EXEC_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))
|
||||
|
||||
which("git", function found (er, git) {
|
||||
if (er) return cb(er)
|
||||
|
||||
exec(git+" init", init)
|
||||
|
||||
function init (er, _, stderr) {
|
||||
if (er) return cb(er)
|
||||
if (stderr) return cb(new Error("git init error: "+stderr))
|
||||
|
||||
exec(git+" config user.name 'Phantom Faker'", user)
|
||||
}
|
||||
|
||||
function user (er, _, stderr) {
|
||||
if (er) return cb(er)
|
||||
if (stderr) return cb(new Error("git config error: "+stderr))
|
||||
|
||||
exec(git+" config user.email nope@not.real", email)
|
||||
}
|
||||
|
||||
function email (er, _, stderr) {
|
||||
if (er) return cb(er)
|
||||
if (stderr) return cb(new Error("git config error: "+stderr))
|
||||
|
||||
exec(git+" add .", addAll)
|
||||
}
|
||||
|
||||
function addAll (er, _, stderr) {
|
||||
if (er) return cb(er)
|
||||
if (stderr) return cb(new Error("git add . error: "+stderr))
|
||||
|
||||
exec(git+" commit -m boot", commit)
|
||||
}
|
||||
|
||||
function commit (er, _, stderr) {
|
||||
if (er) return cb(er)
|
||||
if (stderr) return cb(new Error("git commit error: "+stderr))
|
||||
|
||||
cb()
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
213
node_modules/npm/test/tap/git-races.js
generated
vendored
Normal file
213
node_modules/npm/test/tap/git-races.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
var execFile = require('child_process').execFile
|
||||
var path = require('path')
|
||||
var zlib = require('zlib')
|
||||
|
||||
var asyncMap = require('slide').asyncMap
|
||||
var deepEqual = require('deep-equal')
|
||||
var fs = require('graceful-fs')
|
||||
var mkdirp = require('mkdirp')
|
||||
var once = require('once')
|
||||
var requireInject = require('require-inject')
|
||||
var rimraf = require('rimraf')
|
||||
var tar = require('tar')
|
||||
var test = require('tap').test
|
||||
var tmpdir = require('osenv').tmpdir
|
||||
var which = require('which')
|
||||
|
||||
var wd = path.resolve(tmpdir(), 'git-races')
|
||||
var fixtures = path.resolve(__dirname, '../fixtures')
|
||||
var testcase = 'github-com-BryanDonovan-npm-git-test'
|
||||
var testcase_git = path.resolve(wd, testcase + '.git')
|
||||
var testcase_path = path.resolve(wd, testcase)
|
||||
var testcase_tgz = path.resolve(fixtures, testcase + '.git.tar.gz')
|
||||
|
||||
var testtarballs = []
|
||||
var testrepos = {}
|
||||
var testurls = {}
|
||||
|
||||
/*
|
||||
This test is specifically for #7202, where the bug was if you tried installing multiple git urls that
|
||||
pointed at the same repo but had different comittishes, you'd sometimes get the wrong version.
|
||||
The test cases, provided by @BryanDonovan, have a dependency tree like this:
|
||||
|
||||
top
|
||||
bar#4.0.0
|
||||
buzz#3.0.0
|
||||
foo#3.0.0
|
||||
buzz#3.0.0
|
||||
foo#4.0.0
|
||||
buzz#2.0.0
|
||||
|
||||
But what would happen is that buzz#2.0.0 would end up installed under bar#4.0.0.
|
||||
|
||||
bar#4.0.0 shouldn't have gotten its own copy if buzz, and if it did, it shouldn've been buzz#3.0.0
|
||||
*/
|
||||
|
||||
;['bar', 'foo', 'buzz'].forEach(function (name) {
|
||||
var mockurl = 'ssh://git@github.com/BryanDonovan/dummy-npm-' + name + '.git'
|
||||
var realrepo = path.resolve(wd, 'github-com-BryanDonovan-dummy-npm-' + name + '.git')
|
||||
var tgz = path.resolve(fixtures, 'github-com-BryanDonovan-dummy-npm-' + name + '.git.tar.gz')
|
||||
|
||||
testrepos[mockurl] = realrepo
|
||||
testtarballs.push(tgz)
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(tmpdir())
|
||||
rimraf.sync(wd)
|
||||
}
|
||||
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
// If it's a clone we swap any requests for any of the urls we're mocking
|
||||
// with the path to the bare repo
|
||||
if (args[0] === 'clone') {
|
||||
var m2 = args.length - 2
|
||||
var m1 = args.length - 1
|
||||
if (testrepos[args[m2]]) {
|
||||
testurls[args[m1]] = args[m2]
|
||||
args[m2] = testrepos[args[m2]]
|
||||
}
|
||||
execFile(cmd, args, options, cb)
|
||||
// here, we intercept npm validating the remote origin url on one of the
|
||||
// clones we've done previously and return the original url that was requested
|
||||
} else if (args[0] === 'config' && args[1] === '--get' && args[2] === 'remote.origin.url') {
|
||||
process.nextTick(function () {
|
||||
cb(null, testurls[options.cwd], '')
|
||||
})
|
||||
} else {
|
||||
execFile(cmd, args, options, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function extract (tarball, target, cb) {
|
||||
cb = once(cb)
|
||||
fs.createReadStream(tarball).on('error', function (er) { cb(er) })
|
||||
.pipe(zlib.createGunzip()).on('error', function (er) { cb(er) })
|
||||
.pipe(tar.Extract({path: target})).on('error', function (er) { cb(er) })
|
||||
.on('end', function () {
|
||||
cb()
|
||||
})
|
||||
}
|
||||
|
||||
// Copied from lib/utils/git, because we need to use
|
||||
// it before calling npm.load and lib/utils/git uses npm.js
|
||||
// which doesn't allow that. =( =(
|
||||
|
||||
function prefixGitArgs () {
|
||||
return process.platform === 'win32' ? ['-c', 'core.longpaths=true'] : []
|
||||
}
|
||||
|
||||
var gitcmd
|
||||
|
||||
function execGit (args, options, cb) {
|
||||
var fullArgs = prefixGitArgs().concat(args || [])
|
||||
return execFile(gitcmd, fullArgs, options, cb)
|
||||
}
|
||||
|
||||
function gitWhichAndExec (args, options, cb) {
|
||||
if (gitcmd) return execGit(args, options, cb)
|
||||
|
||||
which('git', function (err, pathtogit) {
|
||||
if (err) {
|
||||
err.code = 'ENOGIT'
|
||||
return cb(err)
|
||||
}
|
||||
gitcmd = pathtogit
|
||||
|
||||
execGit(args, options, cb)
|
||||
})
|
||||
}
|
||||
|
||||
function andClone (gitdir, repodir, cb) {
|
||||
return function (er) {
|
||||
if (er) return cb(er)
|
||||
gitWhichAndExec(['clone', gitdir, repodir], {}, cb)
|
||||
}
|
||||
}
|
||||
|
||||
function setup (cb) {
|
||||
cleanup()
|
||||
mkdirp.sync(wd)
|
||||
|
||||
extract(testcase_tgz, wd, andClone(testcase_git, testcase_path, andExtractPackages))
|
||||
|
||||
function andExtractPackages (er) {
|
||||
if (er) return cb(er)
|
||||
asyncMap(testtarballs, function (tgz, done) {
|
||||
extract(tgz, wd, done)
|
||||
}, andChdir)
|
||||
}
|
||||
function andChdir (er) {
|
||||
if (er) return cb(er)
|
||||
process.chdir(testcase_path)
|
||||
andLoadNpm()
|
||||
}
|
||||
function andLoadNpm () {
|
||||
var opts = {
|
||||
cache: path.resolve(wd, 'cache')
|
||||
}
|
||||
npm.load(opts, cb)
|
||||
}
|
||||
}
|
||||
|
||||
// there are two (sic) valid trees that can result we don't care which one we
|
||||
// get in npm@2
|
||||
var oneTree = [
|
||||
'npm-git-test@1.0.0', [
|
||||
['dummy-npm-bar@4.0.0', [
|
||||
['dummy-npm-foo@3.0.0', []]
|
||||
]],
|
||||
['dummy-npm-buzz@3.0.0', []],
|
||||
['dummy-npm-foo@4.0.0', [
|
||||
['dummy-npm-buzz@2.0.0', []]
|
||||
]]
|
||||
]
|
||||
]
|
||||
var otherTree = [
|
||||
'npm-git-test@1.0.0', [
|
||||
['dummy-npm-bar@4.0.0', [
|
||||
['dummy-npm-buzz@3.0.0', []],
|
||||
['dummy-npm-foo@3.0.0', []]
|
||||
]],
|
||||
['dummy-npm-buzz@3.0.0', []],
|
||||
['dummy-npm-foo@4.0.0', [
|
||||
['dummy-npm-buzz@2.0.0', []]
|
||||
]]
|
||||
]
|
||||
]
|
||||
|
||||
function toSimple (tree) {
|
||||
var deps = []
|
||||
Object.keys(tree.dependencies || {}).forEach(function (dep) {
|
||||
deps.push(toSimple(tree.dependencies[dep]))
|
||||
})
|
||||
return [ tree['name'] + '@' + tree['version'], deps ]
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup(function (er) {
|
||||
t.ifError(er, 'setup ran OK')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('correct versions are installed for git dependency', function (t) {
|
||||
t.plan(3)
|
||||
t.comment('test for https://github.com/npm/npm/issues/7202')
|
||||
npm.commands.install([], function (er) {
|
||||
t.ifError(er, 'installed OK')
|
||||
npm.commands.ls([], true, function (er, result) {
|
||||
t.ifError(er, 'ls OK')
|
||||
var simplified = toSimple(result)
|
||||
t.ok(
|
||||
deepEqual(simplified, oneTree) || deepEqual(simplified, otherTree),
|
||||
'install tree is correct'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
84
node_modules/npm/test/tap/github-shortcut-package.js
generated
vendored
Normal file
84
node_modules/npm/test/tap/github-shortcut-package.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'github-shortcut-package')
|
||||
|
||||
var json = {
|
||||
name: 'github-shortcut-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private': 'foo/private'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
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']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install([], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
81
node_modules/npm/test/tap/github-shortcut.js
generated
vendored
Normal file
81
node_modules/npm/test/tap/github-shortcut.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'github-shortcut')
|
||||
|
||||
var json = {
|
||||
name: 'github-shortcut',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('github-shortcut', 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 third'],
|
||||
['git@github.com:foo/private.git', 'GitHub shortcuts try SSH second']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install(['foo/private'], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
83
node_modules/npm/test/tap/gitlab-shortcut-package.js
generated
vendored
Normal file
83
node_modules/npm/test/tap/gitlab-shortcut-package.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gitlab-shortcut-package')
|
||||
|
||||
var json = {
|
||||
name: 'gitlab-shortcut-package',
|
||||
version: '0.0.0',
|
||||
dependencies: {
|
||||
'private': 'gitlab:foo/private'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('gitlab-shortcut-package', function (t) {
|
||||
var cloneUrls = [
|
||||
['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first'],
|
||||
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install([], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
80
node_modules/npm/test/tap/gitlab-shortcut.js
generated
vendored
Normal file
80
node_modules/npm/test/tap/gitlab-shortcut.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
'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
|
||||
|
||||
var common = require('../common-tap.js')
|
||||
|
||||
var pkg = path.resolve(__dirname, 'gitlab-shortcut')
|
||||
|
||||
var json = {
|
||||
name: 'gitlab-shortcut',
|
||||
version: '0.0.0'
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('gitlab-shortcut', function (t) {
|
||||
var cloneUrls = [
|
||||
['git@gitlab.com:foo/private.git', 'GitLab shortcuts try SSH first'],
|
||||
['https://gitlab.com/foo/private.git', 'GitLab shortcuts try HTTPS URLs second']
|
||||
]
|
||||
var npm = requireInject.installGlobally('../../lib/npm.js', {
|
||||
'child_process': {
|
||||
'execFile': function (cmd, args, options, cb) {
|
||||
process.nextTick(function () {
|
||||
if (args[0] !== 'clone') return cb(null, '', '')
|
||||
var cloneUrl = cloneUrls.shift()
|
||||
if (cloneUrl) {
|
||||
t.is(args[3], cloneUrl[0], cloneUrl[1])
|
||||
} else {
|
||||
t.fail('too many attempts to clone')
|
||||
}
|
||||
cb(new Error())
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
var opts = {
|
||||
cache: path.resolve(pkg, 'cache'),
|
||||
prefix: pkg,
|
||||
registry: common.registry,
|
||||
loglevel: 'silent'
|
||||
}
|
||||
npm.load(opts, function (er) {
|
||||
t.ifError(er, 'npm loaded without error')
|
||||
npm.commands.install(['gitlab:foo/private'], function (er, result) {
|
||||
t.ok(er, 'mocked install failed as expected')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
process.chdir(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
36
node_modules/npm/test/tap/global-prefix-set-in-userconfig.js
generated
vendored
Normal file
36
node_modules/npm/test/tap/global-prefix-set-in-userconfig.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
var common = require("../common-tap.js")
|
||||
var test = require("tap").test
|
||||
var rimraf = require("rimraf")
|
||||
var prefix = __filename.replace(/\.js$/, "")
|
||||
var rcfile = __filename.replace(/\.js$/, ".npmrc")
|
||||
var fs = require("fs")
|
||||
var conf = "prefix = " + prefix + "\n"
|
||||
|
||||
test("setup", function (t) {
|
||||
rimraf.sync(prefix)
|
||||
fs.writeFileSync(rcfile, conf)
|
||||
t.pass("ready")
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("run command", function (t) {
|
||||
var args = ["prefix", "-g", "--userconfig=" + rcfile]
|
||||
common.npm(args, {env: {}}, function (er, code, so) {
|
||||
if (er) throw er
|
||||
t.notOk(code, "npm prefix exited with code 0")
|
||||
t.equal(so.trim(), prefix)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("made dir", function (t) {
|
||||
t.ok(fs.statSync(prefix).isDirectory())
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
rimraf.sync(prefix)
|
||||
rimraf.sync(rcfile)
|
||||
t.pass("clean")
|
||||
t.end()
|
||||
})
|
118
node_modules/npm/test/tap/graceful-restart.js
generated
vendored
Normal file
118
node_modules/npm/test/tap/graceful-restart.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
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 common = require('../common-tap.js')
|
||||
|
||||
var pkg = resolve(__dirname, 'graceful-restart')
|
||||
|
||||
var outGraceless = [
|
||||
'prerestart',
|
||||
'prestop',
|
||||
'stop',
|
||||
'poststop',
|
||||
'prestart',
|
||||
'start',
|
||||
'poststart',
|
||||
'postrestart',
|
||||
''
|
||||
].join('\n')
|
||||
|
||||
var outGraceful = [
|
||||
'prerestart',
|
||||
'restart',
|
||||
'postrestart',
|
||||
''
|
||||
].join('\n')
|
||||
|
||||
var pjGraceless = JSON.stringify({
|
||||
name: 'graceless',
|
||||
version: '1.2.3',
|
||||
scripts: {
|
||||
'prestop': 'echo prestop',
|
||||
'stop': 'echo stop',
|
||||
'poststop': 'echo poststop',
|
||||
'prerestart': 'echo prerestart',
|
||||
'postrestart': 'echo postrestart',
|
||||
'prestart': 'echo prestart',
|
||||
'start': 'echo start',
|
||||
'poststart': 'echo poststart'
|
||||
}
|
||||
}, null, 2) + '\n'
|
||||
|
||||
var pjGraceful = JSON.stringify({
|
||||
name: 'graceful',
|
||||
version: '1.2.3',
|
||||
scripts: {
|
||||
'prestop': 'echo prestop',
|
||||
'stop': 'echo stop',
|
||||
'poststop': 'echo poststop',
|
||||
'prerestart': 'echo prerestart',
|
||||
'restart': 'echo restart',
|
||||
'postrestart': 'echo postrestart',
|
||||
'prestart': 'echo prestart',
|
||||
'start': 'echo start',
|
||||
'poststart': 'echo poststart'
|
||||
}
|
||||
}, null, 2) + '\n'
|
||||
|
||||
test('setup', function (t) {
|
||||
bootstrap()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('graceless restart', function (t) {
|
||||
fs.writeFileSync(resolve(pkg, 'package.json'), pjGraceless)
|
||||
createChild(['run-script', 'restart'], function (err, code, out) {
|
||||
t.ifError(err, 'restart finished successfully')
|
||||
t.equal(code, 0, 'npm run-script exited with code')
|
||||
t.equal(out, outGraceless, 'expected all scripts to run')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('graceful restart', function (t) {
|
||||
fs.writeFileSync(resolve(pkg, 'package.json'), pjGraceful)
|
||||
createChild(['run-script', 'restart'], function (err, code, out) {
|
||||
t.ifError(err, 'restart finished successfully')
|
||||
t.equal(code, 0, 'npm run-script exited with code')
|
||||
t.equal(out, outGraceful, 'expected only *restart scripts to run')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('clean', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function bootstrap () {
|
||||
mkdirp.sync(pkg)
|
||||
}
|
||||
|
||||
function cleanup () {
|
||||
process.chdir(osenv.tmpdir())
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function createChild (args, cb) {
|
||||
var env = {
|
||||
HOME: process.env.HOME,
|
||||
Path: process.env.PATH,
|
||||
PATH: process.env.PATH,
|
||||
'npm_config_loglevel': 'silent'
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
env.npm_config_cache = '%APPDATA%\\npm-cache'
|
||||
|
||||
return common.npm(args, {
|
||||
cwd: pkg,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
env: env
|
||||
}, cb)
|
||||
}
|
69
node_modules/npm/test/tap/ignore-install-link.js
generated
vendored
Normal file
69
node_modules/npm/test/tap/ignore-install-link.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
if (process.platform === "win32") {
|
||||
console.log("ok - symlinks are weird on windows, skip this test")
|
||||
return
|
||||
}
|
||||
var common = require("../common-tap.js")
|
||||
var test = require("tap").test
|
||||
var path = require("path")
|
||||
var fs = require("fs")
|
||||
var rimraf = require("rimraf")
|
||||
var mkdirp = require("mkdirp")
|
||||
|
||||
var root = path.resolve(__dirname, "ignore-install-link")
|
||||
var pkg = path.resolve(root, "pkg")
|
||||
var dep = path.resolve(root, "dep")
|
||||
var target = path.resolve(pkg, "node_modules", "dep")
|
||||
var cache = path.resolve(root, "cache")
|
||||
var globalPath = path.resolve(root, "global")
|
||||
|
||||
var pkgj = { "name":"pkg", "version": "1.2.3"
|
||||
, "dependencies": { "dep": "1.2.3" } }
|
||||
var depj = { "name": "dep", "version": "1.2.3" }
|
||||
|
||||
var myreg = require("http").createServer(function (q, s) {
|
||||
s.statusCode = 403
|
||||
s.end(JSON.stringify({"error":"forbidden"}) + "\n")
|
||||
}).listen(common.port)
|
||||
|
||||
test("setup", function (t) {
|
||||
rimraf.sync(root)
|
||||
mkdirp.sync(root)
|
||||
mkdirp.sync(path.resolve(pkg, "node_modules"))
|
||||
mkdirp.sync(dep)
|
||||
mkdirp.sync(cache)
|
||||
mkdirp.sync(globalPath)
|
||||
fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify(pkgj))
|
||||
fs.writeFileSync(path.resolve(dep, "package.json"), JSON.stringify(depj))
|
||||
fs.symlinkSync(dep, target, "dir")
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("ignore install if package is linked", function (t) {
|
||||
common.npm(["install"], {
|
||||
cwd: pkg,
|
||||
env: {
|
||||
PATH: process.env.PATH || process.env.Path,
|
||||
HOME: process.env.HOME,
|
||||
"npm_config_prefix": globalPath,
|
||||
"npm_config_cache": cache,
|
||||
"npm_config_registry": common.registry,
|
||||
"npm_config_loglevel": "silent"
|
||||
},
|
||||
stdio: "inherit"
|
||||
}, function (er, code) {
|
||||
if (er) throw er
|
||||
t.equal(code, 0, "npm install exited with code")
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test("still a symlink", function (t) {
|
||||
t.equal(true, fs.lstatSync(target).isSymbolicLink())
|
||||
t.end()
|
||||
})
|
||||
|
||||
test("cleanup", function (t) {
|
||||
rimraf.sync(root)
|
||||
myreg.close()
|
||||
t.end()
|
||||
})
|
124
node_modules/npm/test/tap/ignore-scripts.js
generated
vendored
Normal file
124
node_modules/npm/test/tap/ignore-scripts.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
var fs = require('graceful-fs')
|
||||
var path = require('path')
|
||||
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var test = require('tap').test
|
||||
|
||||
var common = require('../common-tap')
|
||||
|
||||
// ignore-scripts/package.json has scripts that always exit with non-zero error
|
||||
// codes.
|
||||
var pkg = path.resolve(__dirname, 'ignore-scripts')
|
||||
|
||||
var gypfile = 'bad_binding_file\n'
|
||||
var json = {
|
||||
author: 'Milton the Aussie',
|
||||
name: 'ignore-scripts',
|
||||
version: '0.0.0',
|
||||
scripts: {
|
||||
prepublish: 'exit 123',
|
||||
publish: 'exit 123',
|
||||
postpublish: 'exit 123',
|
||||
preinstall: 'exit 123',
|
||||
install: 'exit 123',
|
||||
postinstall: 'exit 123',
|
||||
preuninstall: 'exit 123',
|
||||
uninstall: 'exit 123',
|
||||
postuninstall: 'exit 123',
|
||||
pretest: 'exit 123',
|
||||
test: 'exit 123',
|
||||
posttest: 'exit 123',
|
||||
prestop: 'exit 123',
|
||||
stop: 'exit 123',
|
||||
poststop: 'exit 123',
|
||||
prestart: 'exit 123',
|
||||
start: 'exit 123',
|
||||
poststart: 'exit 123',
|
||||
prerestart: 'exit 123',
|
||||
restart: 'exit 123',
|
||||
postrestart: 'exit 123',
|
||||
preversion: 'exit 123',
|
||||
version: 'exit 123',
|
||||
postversion: 'exit 123'
|
||||
}
|
||||
}
|
||||
|
||||
test('setup', function (t) {
|
||||
setup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('ignore-scripts: install using the option', function (t) {
|
||||
createChild(['install', '--ignore-scripts'], function (err, code) {
|
||||
t.ifError(err, 'install with scripts ignored finished successfully')
|
||||
t.equal(code, 0, 'npm install exited with code')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('ignore-scripts: install NOT using the option', function (t) {
|
||||
createChild(['install'], function (err, code) {
|
||||
t.ifError(err, 'install with scripts successful')
|
||||
t.notEqual(code, 0, 'npm install exited with code')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
var scripts = [
|
||||
'prepublish', 'publish', 'postpublish',
|
||||
'preinstall', 'install', 'postinstall',
|
||||
'preuninstall', 'uninstall', 'postuninstall',
|
||||
'pretest', 'test', 'posttest',
|
||||
'prestop', 'stop', 'poststop',
|
||||
'prestart', 'start', 'poststart',
|
||||
'prerestart', 'restart', 'postrestart',
|
||||
'preversion', 'version', 'postversion'
|
||||
]
|
||||
|
||||
scripts.forEach(function (script) {
|
||||
test('ignore-scripts: run-script ' + script + ' using the option', function (t) {
|
||||
createChild(['--ignore-scripts', 'run-script', script], function (err, code, stdout, stderr) {
|
||||
t.ifError(err, 'run-script ' + script + ' with ignore-scripts successful')
|
||||
t.equal(code, 0, 'npm run-script exited with code')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
scripts.forEach(function (script) {
|
||||
test('ignore-scripts: run-script ' + script + ' NOT using the option', function (t) {
|
||||
createChild(['run-script', script], function (err, code) {
|
||||
t.ifError(err, 'run-script ' + script + ' finished successfully')
|
||||
t.notEqual(code, 0, 'npm run-script exited with code')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('cleanup', function (t) {
|
||||
cleanup()
|
||||
t.end()
|
||||
})
|
||||
|
||||
function cleanup () {
|
||||
rimraf.sync(pkg)
|
||||
}
|
||||
|
||||
function setup () {
|
||||
cleanup()
|
||||
mkdirp.sync(pkg)
|
||||
fs.writeFileSync(path.join(pkg, 'binding.gyp'), gypfile)
|
||||
fs.writeFileSync(
|
||||
path.join(pkg, 'package.json'),
|
||||
JSON.stringify(json, null, 2)
|
||||
)
|
||||
}
|
||||
|
||||
function createChild (args, cb) {
|
||||
return common.npm(
|
||||
args.concat(['--loglevel', 'silent']),
|
||||
{ cwd: pkg },
|
||||
cb
|
||||
)
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user