diff options
author | Rebecca Turner <me@re-becca.org> | 2015-07-01 12:13:04 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-07-01 12:13:04 +0300 |
commit | 89741b6f8cbf535952d5d41dd3572e08560ef5f0 (patch) | |
tree | 5c85ab17460a1e0564f0bef2220fa6f0487e1675 /node_modules/npm-registry-client | |
parent | 517fdbb32913642daba59597f7e02b91b8ae4c51 (diff) |
npm-registry-client@6.5.0
Diffstat (limited to 'node_modules/npm-registry-client')
-rw-r--r-- | node_modules/npm-registry-client/lib/ping.js | 23 | ||||
-rw-r--r-- | node_modules/npm-registry-client/package.json | 47 | ||||
-rw-r--r-- | node_modules/npm-registry-client/test/get-403.js | 29 | ||||
-rw-r--r-- | node_modules/npm-registry-client/test/ping.js | 75 |
4 files changed, 153 insertions, 21 deletions
diff --git a/node_modules/npm-registry-client/lib/ping.js b/node_modules/npm-registry-client/lib/ping.js new file mode 100644 index 000000000..b90f99d11 --- /dev/null +++ b/node_modules/npm-registry-client/lib/ping.js @@ -0,0 +1,23 @@ +module.exports = ping + +var url = require('url') +var assert = require('assert') + +function ping (uri, params, cb) { + assert(typeof uri === 'string', 'must pass registry URI to ping') + assert(params && typeof params === 'object', 'must pass params to ping') + assert(typeof cb === 'function', 'must pass callback to ping') + + var auth = params.auth + assert(auth && typeof auth === 'object', 'must pass auth to ping') + + this.request(url.resolve(uri, '-/ping?write=true'), { auth: auth }, function (er, fullData) { + if (er) { + cb(er) + } else if (fullData) { + cb(null, fullData) + } else { + cb(new Error('No data received')) + } + }) +} diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json index 9556d6b4b..3995177b1 100644 --- a/node_modules/npm-registry-client/package.json +++ b/node_modules/npm-registry-client/package.json @@ -1,35 +1,36 @@ { "_args": [ [ - "npm-registry-client@~6.4.0", + "npm-registry-client@6.5.0", "/Users/rebecca/code/npm" ] ], - "_from": "npm-registry-client@>=6.4.0 <6.5.0", - "_id": "npm-registry-client@6.4.0", + "_from": "npm-registry-client@6.5.0", + "_id": "npm-registry-client@6.5.0", "_inCache": true, "_location": "/npm-registry-client", - "_nodeVersion": "1.6.2", + "_nodeVersion": "0.12.5", "_npmUser": { - "email": "me@re-becca.org", - "name": "iarna" + "email": "kat@sykosomatic.org", + "name": "zkat" }, - "_npmVersion": "2.7.6", + "_npmVersion": "3.0.0", "_phantomChildren": {}, "_requested": { "name": "npm-registry-client", - "raw": "npm-registry-client@~6.4.0", - "rawSpec": "~6.4.0", + "raw": "npm-registry-client@6.5.0", + "rawSpec": "6.5.0", "scope": null, - "spec": ">=6.4.0 <6.5.0", - "type": "range" + "spec": "6.5.0", + "type": "version" }, "_requiredBy": [ "/" ], - "_shasum": "4da1adfd1b63c9a7b9a6626eb10e36665c29b5f4", + "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-6.5.0.tgz", + "_shasum": "a1ef783581b5996135be18581b031c043fc80998", "_shrinkwrap": null, - "_spec": "npm-registry-client@~6.4.0", + "_spec": "npm-registry-client@6.5.0", "_where": "/Users/rebecca/code/npm", "author": { "email": "i@izs.me", @@ -58,16 +59,16 @@ "devDependencies": { "negotiator": "^0.4.9", "nock": "^0.56.0", - "standard": "^3.2.0", - "tap": "" + "standard": "^4.0.0", + "tap": "^1.2.0" }, "directories": {}, "dist": { - "shasum": "4da1adfd1b63c9a7b9a6626eb10e36665c29b5f4", - "tarball": "http://registry.npmjs.org/npm-registry-client/-/npm-registry-client-6.4.0.tgz" + "shasum": "a1ef783581b5996135be18581b031c043fc80998", + "tarball": "http://registry.npmjs.org/npm-registry-client/-/npm-registry-client-6.5.0.tgz" }, - "gitHead": "a8d3193832487fb2e6b5015e30d15fe1b15f48e2", - "homepage": "https://github.com/isaacs/npm-registry-client", + "gitHead": "f7370148e6aa015d560941a8192d35ad97823411", + "homepage": "https://github.com/isaacs/npm-registry-client#readme", "license": "ISC", "main": "index.js", "maintainers": [ @@ -82,6 +83,10 @@ { "name": "iarna", "email": "me@re-becca.org" + }, + { + "name": "zkat", + "email": "kat@sykosomatic.org" } ], "name": "npm-registry-client", @@ -89,10 +94,10 @@ "npmlog": "" }, "repository": { - "url": "git://github.com/isaacs/npm-registry-client" + "url": "git://github.com/isaacs/npm-registry-client.git" }, "scripts": { "test": "standard && tap test/*.js" }, - "version": "6.4.0" + "version": "6.5.0" } diff --git a/node_modules/npm-registry-client/test/get-403.js b/node_modules/npm-registry-client/test/get-403.js new file mode 100644 index 000000000..0b8592e50 --- /dev/null +++ b/node_modules/npm-registry-client/test/get-403.js @@ -0,0 +1,29 @@ +var tap = require('tap') + +var server = require('./lib/server.js') +var common = require('./lib/common.js') + +tap.test('get returns 403', function (t) { + server.expect('/underscore', function (req, res) { + t.equal(req.method, 'GET', 'got expected method') + + res.writeHead(403) + res.end(JSON.stringify({ + error: 'get that cat out of the toilet that\'s gross omg' + })) + }) + + var client = common.freshClient() + client.get( + 'http://localhost:1337/underscore', + {}, + function (er) { + t.ok(er, 'failed as expected') + + t.equal(er.statusCode, 403, 'status code was attached to error as expected') + t.equal(er.code, 'E403', 'error code was formatted as expected') + + t.end() + } + ) +}) diff --git a/node_modules/npm-registry-client/test/ping.js b/node_modules/npm-registry-client/test/ping.js new file mode 100644 index 000000000..002d8ba8f --- /dev/null +++ b/node_modules/npm-registry-client/test/ping.js @@ -0,0 +1,75 @@ +var test = require('tap').test + +var server = require('./lib/server.js') +var common = require('./lib/common.js') +var client = common.freshClient() + +function nop () {} + +var TOKEN = 'not-bad-meaning-bad-but-bad-meaning-wombat' +var AUTH = { token: TOKEN } +var PARAMS = { auth: AUTH } +var DEP_USER = 'username' +var HOST = 'localhost' + +test('ping call contract', function (t) { + t.throws(function () { + client.ping(undefined, AUTH, nop) + }, 'requires a URI') + + t.throws(function () { + client.ping([], AUTH, nop) + }, 'requires URI to be a string') + + t.throws(function () { + client.ping(common.registry, undefined, nop) + }, 'requires params object') + + t.throws(function () { + client.ping(common.registry, '', nop) + }, 'params must be object') + + t.throws(function () { + client.ping(common.registry, AUTH, undefined) + }, 'requires callback') + + t.throws(function () { + client.ping(common.registry, AUTH, 'callback') + }, 'callback must be function') + + t.throws( + function () { + var params = {} + client.ping(common.registry, params, nop) + }, + { name: 'AssertionError', message: 'must pass auth to ping' }, + 'must pass auth to ping' + ) + + t.end() +}) + +test('ping', function (t) { + server.expect('GET', '/-/ping?write=true', function (req, res) { + t.equal(req.method, 'GET') + res.statusCode = 200 + res.json({ + ok: true, + host: HOST, + peer: HOST, + username: DEP_USER + }) + }) + + client.ping(common.registry, PARAMS, function (error, found) { + t.ifError(error, 'no errors') + var wanted = { + ok: true, + host: HOST, + peer: HOST, + username: DEP_USER + } + t.same(found, wanted) + t.end() + }) +}) |