Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKat Marchán <kzm@sykosomatic.org>2016-09-08 04:17:59 +0300
committerKat Marchán <kzm@sykosomatic.org>2016-09-09 03:05:27 +0300
commita65ed7cbd3c950383a14461a4b2c87b67ef773b9 (patch)
tree02f9a231e9a8229419cde625351b543ed008ca82 /node_modules/npm-registry-client
parent6c934df6e74bacd0ed40767b319936837a43b586 (diff)
npm-registry-client@7.2.1
* Fix EventEmitter warning spam from error handlers on socket * Add support for streaming request bodies * dependency updates * docs Credit: @othiym23 Fixes: https://github.com/npm/npm/issues/13656
Diffstat (limited to 'node_modules/npm-registry-client')
-rw-r--r--node_modules/npm-registry-client/.travis.yml6
-rw-r--r--node_modules/npm-registry-client/README.md2
-rw-r--r--node_modules/npm-registry-client/lib/publish.js3
-rw-r--r--node_modules/npm-registry-client/lib/request.js44
-rw-r--r--node_modules/npm-registry-client/node_modules/concat-stream/index.js19
-rw-r--r--node_modules/npm-registry-client/node_modules/concat-stream/package.json135
-rw-r--r--node_modules/npm-registry-client/node_modules/concat-stream/readme.md2
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/README.md46
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/example/dns.js2
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/example/stop.js40
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/lib/retry.js11
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js29
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/package.json54
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/test/integration/test-forever.js24
-rw-r--r--node_modules/npm-registry-client/node_modules/retry/test/integration/test-retry-operation.js70
-rw-r--r--node_modules/npm-registry-client/package.json100
-rw-r--r--node_modules/npm-registry-client/test/00-setup.js5
-rw-r--r--node_modules/npm-registry-client/test/config-defaults.js2
-rw-r--r--node_modules/npm-registry-client/test/fetch-streaming.js58
-rw-r--r--node_modules/npm-registry-client/test/initialize.js4
-rw-r--r--node_modules/npm-registry-client/test/lib/common.js8
-rw-r--r--node_modules/npm-registry-client/test/zz-cleanup.js5
22 files changed, 512 insertions, 157 deletions
diff --git a/node_modules/npm-registry-client/.travis.yml b/node_modules/npm-registry-client/.travis.yml
index 3669bc76e..2993ae58c 100644
--- a/node_modules/npm-registry-client/.travis.yml
+++ b/node_modules/npm-registry-client/.travis.yml
@@ -1,9 +1,9 @@
language: node_js
node_js:
- - "0.12"
+ - "4"
+ - "6"
- "0.10"
- - "0.8"
- - iojs
+ - "0.12"
script: "npm test"
sudo: false
before_install:
diff --git a/node_modules/npm-registry-client/README.md b/node_modules/npm-registry-client/README.md
index 2caa36437..9d81f4df3 100644
--- a/node_modules/npm-registry-client/README.md
+++ b/node_modules/npm-registry-client/README.md
@@ -259,6 +259,8 @@ caching logic directly.
* `etag` {String} The cached ETag. Optional.
* `lastModified` {String} The cached Last-Modified timestamp. Optional.
* `follow` {Boolean} Follow 302/301 responses. Optional (default: true).
+ * `streaming` {Boolean} Stream the request body as it comes, handling error
+ responses in a non-streaming way.
* `auth` {Credentials} Optional.
* `cb` {Function}
* `error` {Error | null}
diff --git a/node_modules/npm-registry-client/lib/publish.js b/node_modules/npm-registry-client/lib/publish.js
index 13e61debf..9bf1c3066 100644
--- a/node_modules/npm-registry-client/lib/publish.js
+++ b/node_modules/npm-registry-client/lib/publish.js
@@ -153,8 +153,9 @@ function putNext (registry, newVersion, root, current, auth, cb) {
case 'dist-tags':
case 'versions':
case '_attachments':
- for (var j in root[i])
+ for (var j in root[i]) {
current[i][j] = root[i][j]
+ }
break
// ignore these
diff --git a/node_modules/npm-registry-client/lib/request.js b/node_modules/npm-registry-client/lib/request.js
index 567fc8dbe..04be044d6 100644
--- a/node_modules/npm-registry-client/lib/request.js
+++ b/node_modules/npm-registry-client/lib/request.js
@@ -92,7 +92,16 @@ function regRequest (uri, params, cb_) {
}
function makeRequest (uri, params, cb_) {
- var cb = once(cb_)
+ var socket
+ var cb = once(function (er, parsed, raw, response) {
+ if (socket) {
+ // The socket might be returned to a pool for re-use, so don’t keep
+ // the 'error' listener from here attached.
+ socket.removeListener('error', cb)
+ }
+
+ return cb_(er, parsed, raw, response)
+ })
var parsed = url.parse(uri)
var headers = {}
@@ -146,13 +155,42 @@ function makeRequest (uri, params, cb_) {
this.log.http('request', params.method, parsed.href || '/')
var done = requestDone.call(this, params.method, uri, cb)
- var req = request(opts, decodeResponseBody(done))
+ var req = request(opts, params.streaming ? undefined : decodeResponseBody(done))
req.on('error', cb)
+
+ // This should not be necessary, as the HTTP implementation in Node
+ // passes errors occurring on the socket to the request itself. Being overly
+ // cautious comes at a low cost, though.
req.on('socket', function (s) {
- s.on('error', cb)
+ socket = s
+ socket.on('error', cb)
})
+ if (params.streaming) {
+ req.on('response', function (response) {
+ if (response.statusCode >= 400) {
+ var parts = []
+ response.on('data', function (data) {
+ parts.push(data)
+ })
+ response.on('end', function () {
+ decodeResponseBody(done)(null, response, Buffer.concat(parts))
+ })
+ } else {
+ response.on('end', function () {
+ // don't ever re-use connections that had server errors.
+ // those sockets connect to the Bad Place!
+ if (response.socket && response.statusCode > 500) {
+ response.socket.destroy()
+ }
+ })
+
+ return cb(null, response)
+ }
+ })
+ }
+
if (params.body && (params.body instanceof Stream)) {
params.body.pipe(req)
}
diff --git a/node_modules/npm-registry-client/node_modules/concat-stream/index.js b/node_modules/npm-registry-client/node_modules/concat-stream/index.js
index b55ae7e03..b16ad1343 100644
--- a/node_modules/npm-registry-client/node_modules/concat-stream/index.js
+++ b/node_modules/npm-registry-client/node_modules/concat-stream/index.js
@@ -73,6 +73,10 @@ function isArrayish (arr) {
return /Array\]$/.test(Object.prototype.toString.call(arr))
}
+function isBufferish (p) {
+ return typeof p === 'string' || isArrayish(p) || (p && typeof p.subarray === 'function')
+}
+
function stringConcat (parts) {
var strings = []
var needsToString = false
@@ -82,8 +86,10 @@ function stringConcat (parts) {
strings.push(p)
} else if (Buffer.isBuffer(p)) {
strings.push(p)
+ } else if (isBufferish(p)) {
+ strings.push(new Buffer(p))
} else {
- strings.push(Buffer(p))
+ strings.push(new Buffer(String(p)))
}
}
if (Buffer.isBuffer(parts[0])) {
@@ -101,10 +107,11 @@ function bufferConcat (parts) {
var p = parts[i]
if (Buffer.isBuffer(p)) {
bufs.push(p)
- } else if (typeof p === 'string' || isArrayish(p)
- || (p && typeof p.subarray === 'function')) {
- bufs.push(Buffer(p))
- } else bufs.push(Buffer(String(p)))
+ } else if (isBufferish(p)) {
+ bufs.push(new Buffer(p))
+ } else {
+ bufs.push(new Buffer(String(p)))
+ }
}
return Buffer.concat(bufs)
}
@@ -121,7 +128,7 @@ function u8Concat (parts) {
var len = 0
for (var i = 0; i < parts.length; i++) {
if (typeof parts[i] === 'string') {
- parts[i] = Buffer(parts[i])
+ parts[i] = new Buffer(parts[i])
}
len += parts[i].length
}
diff --git a/node_modules/npm-registry-client/node_modules/concat-stream/package.json b/node_modules/npm-registry-client/node_modules/concat-stream/package.json
index 5a3f8b401..7c8b5de3b 100644
--- a/node_modules/npm-registry-client/node_modules/concat-stream/package.json
+++ b/node_modules/npm-registry-client/node_modules/concat-stream/package.json
@@ -1,43 +1,109 @@
{
- "name": "concat-stream",
- "version": "1.5.1",
- "description": "writable stream that concatenates strings or binary data and calls a callback with the result",
- "tags": [
- "stream",
- "simple",
- "util",
- "utility"
+ "_args": [
+ [
+ {
+ "raw": "concat-stream@^1.5.2",
+ "scope": null,
+ "escapedName": "concat-stream",
+ "name": "concat-stream",
+ "rawSpec": "^1.5.2",
+ "spec": ">=1.5.2 <2.0.0",
+ "type": "range"
+ },
+ "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client"
+ ]
+ ],
+ "_from": "concat-stream@>=1.5.2 <2.0.0",
+ "_id": "concat-stream@1.5.2",
+ "_inCache": true,
+ "_location": "/npm-registry-client/concat-stream",
+ "_nodeVersion": "4.4.3",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/concat-stream-1.5.2.tgz_1472715196934_0.010375389130786061"
+ },
+ "_npmUser": {
+ "name": "mafintosh",
+ "email": "mathiasbuus@gmail.com"
+ },
+ "_npmVersion": "2.15.9",
+ "_phantomChildren": {
+ "inherits": "2.0.3"
+ },
+ "_requested": {
+ "raw": "concat-stream@^1.5.2",
+ "scope": null,
+ "escapedName": "concat-stream",
+ "name": "concat-stream",
+ "rawSpec": "^1.5.2",
+ "spec": ">=1.5.2 <2.0.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/npm-registry-client"
],
+ "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz",
+ "_shasum": "708978624d856af41a5a741defdd261da752c266",
+ "_shrinkwrap": null,
+ "_spec": "concat-stream@^1.5.2",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client",
"author": {
"name": "Max Ogden",
"email": "max@maxogden.com"
},
- "repository": {
- "type": "git",
- "url": "git+ssh://git@github.com/maxogden/concat-stream.git"
- },
"bugs": {
"url": "http://github.com/maxogden/concat-stream/issues"
},
+ "dependencies": {
+ "inherits": "~2.0.1",
+ "readable-stream": "~2.0.0",
+ "typedarray": "~0.0.5"
+ },
+ "description": "writable stream that concatenates strings or binary data and calls a callback with the result",
+ "devDependencies": {
+ "tape": "~2.3.2"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "708978624d856af41a5a741defdd261da752c266",
+ "tarball": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz"
+ },
"engines": [
"node >= 0.8"
],
- "main": "index.js",
"files": [
"index.js"
],
- "scripts": {
- "test": "tape test/*.js test/server/*.js"
- },
+ "gitHead": "731fedd137eae89d066c249fdca070f8f16afbb8",
+ "homepage": "https://github.com/maxogden/concat-stream#readme",
"license": "MIT",
- "dependencies": {
- "inherits": "~2.0.1",
- "typedarray": "~0.0.5",
- "readable-stream": "~2.0.0"
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "mafintosh",
+ "email": "mathiasbuus@gmail.com"
+ },
+ {
+ "name": "maxogden",
+ "email": "max@maxogden.com"
+ }
+ ],
+ "name": "concat-stream",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/maxogden/concat-stream.git"
},
- "devDependencies": {
- "tape": "~2.3.2"
+ "scripts": {
+ "test": "tape test/*.js test/server/*.js"
},
+ "tags": [
+ "stream",
+ "simple",
+ "util",
+ "utility"
+ ],
"testling": {
"files": "test/*.js",
"browsers": [
@@ -54,28 +120,5 @@
"android-browser/4.2..latest"
]
},
- "gitHead": "522adc12d82f57c691a5f946fbc8ba08718dcdcb",
- "homepage": "https://github.com/maxogden/concat-stream#readme",
- "_id": "concat-stream@1.5.1",
- "_shasum": "f3b80acf9e1f48e3875c0688b41b6c31602eea1c",
- "_from": "concat-stream@>=1.4.6 <2.0.0",
- "_npmVersion": "2.14.2",
- "_nodeVersion": "4.0.0",
- "_npmUser": {
- "name": "maxogden",
- "email": "max@maxogden.com"
- },
- "dist": {
- "shasum": "f3b80acf9e1f48e3875c0688b41b6c31602eea1c",
- "tarball": "http://registry.npmjs.org/concat-stream/-/concat-stream-1.5.1.tgz"
- },
- "maintainers": [
- {
- "name": "maxogden",
- "email": "max@maxogden.com"
- }
- ],
- "directories": {},
- "_resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.1.tgz",
- "readme": "ERROR: No README data found!"
+ "version": "1.5.2"
}
diff --git a/node_modules/npm-registry-client/node_modules/concat-stream/readme.md b/node_modules/npm-registry-client/node_modules/concat-stream/readme.md
index 1a16af94c..8ad4197c9 100644
--- a/node_modules/npm-registry-client/node_modules/concat-stream/readme.md
+++ b/node_modules/npm-registry-client/node_modules/concat-stream/readme.md
@@ -89,6 +89,8 @@ By default `concat-stream` will give you back the same data type as the type of
If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a `Buffer`.
+If nothing is written to `writable` then `data` will be an empty array `[]`.
+
# error handling
`concat-stream` does not handle errors for you, so you must handle errors on whatever streams you pipe into `concat-stream`. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since `concat-stream` is not itself a stream it does not emit errors.
diff --git a/node_modules/npm-registry-client/node_modules/retry/README.md b/node_modules/npm-registry-client/node_modules/retry/README.md
index 09d9c8a81..eee05f7bb 100644
--- a/node_modules/npm-registry-client/node_modules/retry/README.md
+++ b/node_modules/npm-registry-client/node_modules/retry/README.md
@@ -57,8 +57,10 @@ var operation = retry.operation({
### retry.operation([options])
-Creates a new `RetryOperation` object. See the `retry.timeouts()` function
-below for available `options`.
+Creates a new `RetryOperation` object. `options` is the same as `retry.timeouts()`'s `options`, with two additions:
+
+* `forever`: Whether to retry forever, defaults to `false`.
+* `unref`: Wether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
### retry.timeouts([options])
@@ -76,7 +78,7 @@ milliseconds. If `options` is an array, a copy of that array is returned.
The formula used to calculate the individual timeouts is:
```
-var Math.min(random * minTimeout * Math.pow(factor, attempt), maxTimeout);
+Math.min(random * minTimeout * Math.pow(factor, attempt), maxTimeout)
```
Have a look at [this article][article] for a better explanation of approach.
@@ -118,19 +120,27 @@ an array of method names which need to be wrapped.
```
retry.wrap(obj)
-retry.wrap(obj, ['method1', 'method2']);
+retry.wrap(obj, ['method1', 'method2'])
-retry.wrap(obj, {retries: 3});
+retry.wrap(obj, {retries: 3})
-retry.wrap(obj, {retries: 3}, ['method1', 'method2']);
+retry.wrap(obj, {retries: 3}, ['method1', 'method2'])
```
The `options` object can take any options that the usual call to `retry.operation` can take.
-### new RetryOperation(timeouts)
+### new RetryOperation(timeouts, [options])
Creates a new `RetryOperation` where `timeouts` is an array where each value is
a timeout given in milliseconds.
+Available options:
+* `forever`: Whether to retry forever, defaults to `false`.
+* `unref`: Wether to [unref](https://nodejs.org/api/timers.html#timers_unref) the setTimeout's, defaults to `false`.
+
+If `forever` is true, the following changes happen:
+* `RetryOperation.errors()` will only output an array of one item: the last error.
+* `RetryOperation` will repeatedly use the `timeouts` array. Once all of its timeouts have been used up, it restarts with the first timeout, then uses the second and so on.
+
#### retryOperation.errors()
Returns an array of all errors that have been passed to
@@ -157,11 +167,11 @@ Whenever your retry operation takes longer than `timeout` to execute, the timeou
#### retryOperation.try(fn)
-This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
+This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
#### retryOperation.start(fn)
-This is an alias for `retryOperation.attempt(fn)`. This is deprecated.
+This is an alias for `retryOperation.attempt(fn)`. This is deprecated. Please use `retryOperation.attempt(fn)` instead.
#### retryOperation.retry(error)
@@ -171,6 +181,10 @@ has been reached.
Otherwise it returns `true`, and retries the operation after the timeout for
the current attempt number.
+#### retryOperation.stop()
+
+Allows you to stop the operation being retried. Useful for aborting the operation on a fatal error etc.
+
#### retryOperation.attempts()
Returns an int representing the number of attempts it took to call `fn` before it was successful.
@@ -180,13 +194,19 @@ Returns an int representing the number of attempts it took to call `fn` before i
retry is licensed under the MIT license.
-#Changelog
+# Changelog
+
+0.10.0 Adding `stop` functionality, thanks to @maxnachlinger.
+
+0.9.0 Adding `unref` functionality, thanks to @satazor.
+
+0.8.0 Implementing retry.wrap.
-0.7.0 Some bugfixes and made retry.createTimeout() public. Fixed issues [#10](https://github.com/tim-kos/node-retry/issues/10), [#12](https://github.com/tim-kos/node-retry/issues/12), and [#13](https://github.com/tim-kos/node-retry/issues/13).
+0.7.0 Some bug fixes and made retry.createTimeout() public. Fixed issues [#10](https://github.com/tim-kos/node-retry/issues/10), [#12](https://github.com/tim-kos/node-retry/issues/12), and [#13](https://github.com/tim-kos/node-retry/issues/13).
-0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in miliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
+0.6.0 Introduced optional timeOps parameter for the attempt() function which is an object having a property timeout in milliseconds and a property cb callback function. Whenever your retry operation takes longer than timeout to execute, the timeout callback function cb is called.
-0.5.0 Some minor refactorings.
+0.5.0 Some minor refactoring.
0.4.0 Changed retryOperation.try() to retryOperation.attempt(). Deprecated the aliases start() and try() for it.
diff --git a/node_modules/npm-registry-client/node_modules/retry/example/dns.js b/node_modules/npm-registry-client/node_modules/retry/example/dns.js
index d6351e9d0..446729b6f 100644
--- a/node_modules/npm-registry-client/node_modules/retry/example/dns.js
+++ b/node_modules/npm-registry-client/node_modules/retry/example/dns.js
@@ -28,4 +28,4 @@ faultTolerantResolve('nodejs.org', function(err, errors, addresses) {
console.warn('addresses:');
console.log(addresses);
-});
+}); \ No newline at end of file
diff --git a/node_modules/npm-registry-client/node_modules/retry/example/stop.js b/node_modules/npm-registry-client/node_modules/retry/example/stop.js
new file mode 100644
index 000000000..e1ceafeeb
--- /dev/null
+++ b/node_modules/npm-registry-client/node_modules/retry/example/stop.js
@@ -0,0 +1,40 @@
+var retry = require('../lib/retry');
+
+function attemptAsyncOperation(someInput, cb) {
+ var opts = {
+ retries: 2,
+ factor: 2,
+ minTimeout: 1 * 1000,
+ maxTimeout: 2 * 1000,
+ randomize: true
+ };
+ var operation = retry.operation(opts);
+
+ operation.attempt(function(currentAttempt) {
+ failingAsyncOperation(someInput, function(err, result) {
+
+ if (err && err.message === 'A fatal error') {
+ operation.stop();
+ return cb(err);
+ }
+
+ if (operation.retry(err)) {
+ return;
+ }
+
+ cb(operation.mainError(), operation.errors(), result);
+ });
+ });
+}
+
+attemptAsyncOperation('test input', function(err, errors, result) {
+ console.warn('err:');
+ console.log(err);
+
+ console.warn('result:');
+ console.log(result);
+});
+
+function failingAsyncOperation(input, cb) {
+ return setImmediate(cb.bind(null, new Error('A fatal error')));
+}
diff --git a/node_modules/npm-registry-client/node_modules/retry/lib/retry.js b/node_modules/npm-registry-client/node_modules/retry/lib/retry.js
index 94685652c..77428cfd0 100644
--- a/node_modules/npm-registry-client/node_modules/retry/lib/retry.js
+++ b/node_modules/npm-registry-client/node_modules/retry/lib/retry.js
@@ -1,10 +1,11 @@
var RetryOperation = require('./retry_operation');
exports.operation = function(options) {
- var retryForever = false;
- if (options && options.forever === true) retryForever = true;
var timeouts = exports.timeouts(options);
- return new RetryOperation(timeouts, retryForever);
+ return new RetryOperation(timeouts, {
+ forever: options && options.forever,
+ unref: options && options.unref
+ });
};
exports.timeouts = function(options) {
@@ -32,6 +33,10 @@ exports.timeouts = function(options) {
timeouts.push(this.createTimeout(i, opts));
}
+ if (options && options.forever && !timeouts.length) {
+ timeouts.push(this.createTimeout(i, opts));
+ }
+
// sort the array numerically ascending
timeouts.sort(function(a,b) {
return a - b;
diff --git a/node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js b/node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js
index 52b895544..2b3db8e17 100644
--- a/node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js
+++ b/node_modules/npm-registry-client/node_modules/retry/lib/retry_operation.js
@@ -1,5 +1,11 @@
-function RetryOperation(timeouts, retryForever) {
+function RetryOperation(timeouts, options) {
+ // Compatibility for the old (timeouts, retryForever) signature
+ if (typeof options === 'boolean') {
+ options = { forever: options };
+ }
+
this._timeouts = timeouts;
+ this._options = options || {};
this._fn = null;
this._errors = [];
this._attempts = 1;
@@ -7,12 +13,21 @@ function RetryOperation(timeouts, retryForever) {
this._operationTimeoutCb = null;
this._timeout = null;
- if (!!retryForever) {
+ if (this._options.forever) {
this._cachedTimeouts = this._timeouts.slice(0);
}
}
module.exports = RetryOperation;
+RetryOperation.prototype.stop = function() {
+ if (this._timeout) {
+ clearTimeout(this._timeout);
+ }
+
+ this._timeouts = [];
+ this._cachedTimeouts = null;
+};
+
RetryOperation.prototype.retry = function(err) {
if (this._timeout) {
clearTimeout(this._timeout);
@@ -37,18 +52,26 @@ RetryOperation.prototype.retry = function(err) {
}
var self = this;
- setTimeout(function() {
+ var timer = setTimeout(function() {
self._attempts++;
if (self._operationTimeoutCb) {
self._timeout = setTimeout(function() {
self._operationTimeoutCb(self._attempts);
}, self._operationTimeout);
+
+ if (this._options.unref) {
+ self._timeout.unref();
+ }
}
self._fn(self._attempts);
}, timeout);
+ if (this._options.unref) {
+ timer.unref();
+ }
+
return true;
};
diff --git a/node_modules/npm-registry-client/node_modules/retry/package.json b/node_modules/npm-registry-client/node_modules/retry/package.json
index c274f9d6a..0ba214a6f 100644
--- a/node_modules/npm-registry-client/node_modules/retry/package.json
+++ b/node_modules/npm-registry-client/node_modules/retry/package.json
@@ -1,41 +1,53 @@
{
"_args": [
[
- "retry@^0.8.0",
- "/Users/rebecca/code/npm/node_modules/npm-registry-client"
+ {
+ "raw": "retry@^0.10.0",
+ "scope": null,
+ "escapedName": "retry",
+ "name": "retry",
+ "rawSpec": "^0.10.0",
+ "spec": ">=0.10.0 <0.11.0",
+ "type": "range"
+ },
+ "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client"
]
],
- "_from": "retry@>=0.8.0 <0.9.0",
- "_id": "retry@0.8.0",
+ "_from": "retry@>=0.10.0 <0.11.0",
+ "_id": "retry@0.10.0",
"_inCache": true,
- "_installable": true,
"_location": "/npm-registry-client/retry",
- "_nodeVersion": "0.10.33",
+ "_nodeVersion": "4.2.1",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/retry-0.10.0.tgz_1471682099847_0.5031970851123333"
+ },
"_npmUser": {
- "email": "tim@debuggable.com",
- "name": "tim-kos"
+ "name": "tim-kos",
+ "email": "tim@debuggable.com"
},
"_npmVersion": "2.1.7",
"_phantomChildren": {},
"_requested": {
- "name": "retry",
- "raw": "retry@^0.8.0",
- "rawSpec": "^0.8.0",
+ "raw": "retry@^0.10.0",
"scope": null,
- "spec": ">=0.8.0 <0.9.0",
+ "escapedName": "retry",
+ "name": "retry",
+ "rawSpec": "^0.10.0",
+ "spec": ">=0.10.0 <0.11.0",
"type": "range"
},
"_requiredBy": [
"/npm-registry-client"
],
- "_resolved": "https://registry.npmjs.org/retry/-/retry-0.8.0.tgz",
- "_shasum": "2367628dc0edb247b1eab649dc53ac8628ac2d5f",
+ "_resolved": "https://registry.npmjs.org/retry/-/retry-0.10.0.tgz",
+ "_shasum": "649e15ca408422d98318161935e7f7d652d435dd",
"_shrinkwrap": null,
- "_spec": "retry@^0.8.0",
- "_where": "/Users/rebecca/code/npm/node_modules/npm-registry-client",
+ "_spec": "retry@^0.10.0",
+ "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client",
"author": {
- "email": "tim@debuggable.com",
"name": "Tim Koschützki",
+ "email": "tim@debuggable.com",
"url": "http://debuggable.com/"
},
"bugs": {
@@ -51,13 +63,13 @@
"lib": "./lib"
},
"dist": {
- "shasum": "2367628dc0edb247b1eab649dc53ac8628ac2d5f",
- "tarball": "http://registry.npmjs.org/retry/-/retry-0.8.0.tgz"
+ "shasum": "649e15ca408422d98318161935e7f7d652d435dd",
+ "tarball": "https://registry.npmjs.org/retry/-/retry-0.10.0.tgz"
},
"engines": {
"node": "*"
},
- "gitHead": "9446e803d6a41ae08732a4a215ae5bf1ff1ccfdd",
+ "gitHead": "0616e6a6ebc49b5a36b619c8f7c414ced8c3813b",
"homepage": "https://github.com/tim-kos/node-retry",
"license": "MIT",
"main": "index",
@@ -75,5 +87,5 @@
"url": "git://github.com/tim-kos/node-retry.git"
},
"scripts": {},
- "version": "0.8.0"
+ "version": "0.10.0"
}
diff --git a/node_modules/npm-registry-client/node_modules/retry/test/integration/test-forever.js b/node_modules/npm-registry-client/node_modules/retry/test/integration/test-forever.js
new file mode 100644
index 000000000..b41307cb5
--- /dev/null
+++ b/node_modules/npm-registry-client/node_modules/retry/test/integration/test-forever.js
@@ -0,0 +1,24 @@
+var common = require('../common');
+var assert = common.assert;
+var retry = require(common.dir.lib + '/retry');
+
+(function testForeverUsesFirstTimeout() {
+ var operation = retry.operation({
+ retries: 0,
+ minTimeout: 100,
+ maxTimeout: 100,
+ forever: true
+ });
+
+ operation.attempt(function(numAttempt) {
+ console.log('>numAttempt', numAttempt);
+ var err = new Error("foo");
+ if (numAttempt == 10) {
+ operation.stop();
+ }
+
+ if (operation.retry(err)) {
+ return;
+ }
+ });
+})();
diff --git a/node_modules/npm-registry-client/node_modules/retry/test/integration/test-retry-operation.js b/node_modules/npm-registry-client/node_modules/retry/test/integration/test-retry-operation.js
index cecfa3b73..916936424 100644
--- a/node_modules/npm-registry-client/node_modules/retry/test/integration/test-retry-operation.js
+++ b/node_modules/npm-registry-client/node_modules/retry/test/integration/test-retry-operation.js
@@ -104,3 +104,73 @@ var retry = require(common.dir.lib + '/retry');
fn();
})();
+
+(function testRetryForeverNoRetries() {
+ var error = new Error('some error');
+ var delay = 50
+ var operation = retry.operation({
+ retries: null,
+ forever: true,
+ minTimeout: delay,
+ maxTimeout: delay
+ });
+
+ var attempts = 0;
+ var startTime = new Date().getTime();
+
+ var finalCallback = fake.callback('finalCallback');
+ fake.expectAnytime(finalCallback);
+
+ var fn = function() {
+ operation.attempt(function(currentAttempt) {
+ attempts++;
+ assert.equal(currentAttempt, attempts);
+ if (attempts !== 4 && operation.retry(error)) {
+ return;
+ }
+
+ var endTime = new Date().getTime();
+ var minTime = startTime + (delay * 3);
+ var maxTime = minTime + 20 // add a little headroom for code execution time
+ assert(endTime > minTime)
+ assert(endTime < maxTime)
+ assert.strictEqual(attempts, 4);
+ assert.strictEqual(operation.attempts(), attempts);
+ assert.strictEqual(operation.mainError(), error);
+ finalCallback();
+ });
+ };
+
+ fn();
+})();
+
+(function testStop() {
+ var error = new Error('some error');
+ var operation = retry.operation([1, 2, 3]);
+ var attempts = 0;
+
+ var finalCallback = fake.callback('finalCallback');
+ fake.expectAnytime(finalCallback);
+
+ var fn = function() {
+ operation.attempt(function(currentAttempt) {
+ attempts++;
+ assert.equal(currentAttempt, attempts);
+
+ if (attempts === 2) {
+ operation.stop();
+
+ assert.strictEqual(attempts, 2);
+ assert.strictEqual(operation.attempts(), attempts);
+ assert.strictEqual(operation.mainError(), error);
+ finalCallback();
+ }
+
+ if (operation.retry(error)) {
+ return;
+ }
+ });
+ };
+
+ fn();
+})();
diff --git a/node_modules/npm-registry-client/package.json b/node_modules/npm-registry-client/package.json
index 20ff75226..51ff6bebb 100644
--- a/node_modules/npm-registry-client/package.json
+++ b/node_modules/npm-registry-client/package.json
@@ -2,106 +2,106 @@
"_args": [
[
{
- "name": "npm-registry-client",
- "raw": "npm-registry-client@latest",
- "rawSpec": "latest",
+ "raw": "npm-registry-client@7.2.1",
"scope": null,
- "spec": "latest",
- "type": "tag"
+ "escapedName": "npm-registry-client",
+ "name": "npm-registry-client",
+ "rawSpec": "7.2.1",
+ "spec": "7.2.1",
+ "type": "version"
},
- "/Users/rebecca/code/npm"
+ "/Users/zkat/Documents/code/npm"
]
],
- "_from": "npm-registry-client@latest",
- "_id": "npm-registry-client@7.1.2",
+ "_from": "npm-registry-client@7.2.1",
+ "_id": "npm-registry-client@7.2.1",
"_inCache": true,
- "_installable": true,
"_location": "/npm-registry-client",
- "_nodeVersion": "4.4.0",
+ "_nodeVersion": "6.3.1",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
- "tmp": "tmp/npm-registry-client-7.1.2.tgz_1466040796551_0.645394338760525"
+ "tmp": "tmp/npm-registry-client-7.2.1.tgz_1472871043942_0.2117650501895696"
},
"_npmUser": {
- "email": "me@re-becca.org",
- "name": "iarna"
+ "name": "othiym23",
+ "email": "ogd@aoaioxxysz.net"
},
- "_npmVersion": "3.9.2",
+ "_npmVersion": "3.10.7",
"_phantomChildren": {
- "inherits": "2.0.1"
+ "inherits": "2.0.3"
},
"_requested": {
- "name": "npm-registry-client",
- "raw": "npm-registry-client@latest",
- "rawSpec": "latest",
+ "raw": "npm-registry-client@7.2.1",
"scope": null,
- "spec": "latest",
- "type": "tag"
+ "escapedName": "npm-registry-client",
+ "name": "npm-registry-client",
+ "rawSpec": "7.2.1",
+ "spec": "7.2.1",
+ "type": "version"
},
"_requiredBy": [
+ "#USER",
"/"
],
- "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.1.2.tgz",
- "_shasum": "ddf243a2bd149d35172fe680aff40dfa20054bc3",
+ "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.2.1.tgz",
+ "_shasum": "c792266b088cc313f8525e7e35248626c723db75",
"_shrinkwrap": null,
- "_spec": "npm-registry-client@latest",
- "_where": "/Users/rebecca/code/npm",
+ "_spec": "npm-registry-client@7.2.1",
+ "_where": "/Users/zkat/Documents/code/npm",
"author": {
- "email": "i@izs.me",
"name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/npm/npm-registry-client/issues"
},
"dependencies": {
- "chownr": "^1.0.1",
- "concat-stream": "^1.4.6",
- "graceful-fs": "^4.1.2",
- "mkdirp": "^0.5.0",
+ "concat-stream": "^1.5.2",
+ "graceful-fs": "^4.1.6",
"normalize-package-data": "~1.0.1 || ^2.0.0",
"npm-package-arg": "^3.0.0 || ^4.0.0",
"npmlog": "~2.0.0 || ~3.1.0",
- "once": "^1.3.0",
- "request": "^2.47.0",
- "retry": "^0.8.0",
- "rimraf": "2",
+ "once": "^1.3.3",
+ "request": "^2.74.0",
+ "retry": "^0.10.0",
"semver": "2 >=2.2.1 || 3.x || 4 || 5",
"slide": "^1.1.3"
},
"description": "Client for the npm registry",
"devDependencies": {
- "negotiator": "^0.4.9",
- "nock": "^0.56.0",
- "readable-stream": "^2.0.2",
- "standard": "^4.0.0",
- "tap": "^1.2.0"
+ "negotiator": "^0.6.1",
+ "nock": "^8.0.0",
+ "readable-stream": "^2.1.5",
+ "rimraf": "^2.5.4",
+ "standard": "^8.0.0",
+ "tap": "^7.0.0"
},
"directories": {},
"dist": {
- "shasum": "ddf243a2bd149d35172fe680aff40dfa20054bc3",
- "tarball": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.1.2.tgz"
+ "shasum": "c792266b088cc313f8525e7e35248626c723db75",
+ "tarball": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.2.1.tgz"
},
- "gitHead": "0b595c4769f314a12661d537a328cf4e5658a00f",
+ "gitHead": "debec76884db8092c2c7a21ab5b4ed083f8ce2c9",
"homepage": "https://github.com/npm/npm-registry-client#readme",
"license": "ISC",
"main": "index.js",
"maintainers": [
{
- "email": "isaacs@npmjs.com",
- "name": "isaacs"
+ "name": "isaacs",
+ "email": "isaacs@npmjs.com"
},
{
- "email": "ogd@aoaioxxysz.net",
- "name": "othiym23"
+ "name": "othiym23",
+ "email": "ogd@aoaioxxysz.net"
},
{
- "email": "me@re-becca.org",
- "name": "iarna"
+ "name": "iarna",
+ "email": "me@re-becca.org"
},
{
- "email": "kat@sykosomatic.org",
- "name": "zkat"
+ "name": "zkat",
+ "email": "kat@sykosomatic.org"
}
],
"name": "npm-registry-client",
@@ -115,5 +115,5 @@
"scripts": {
"test": "standard && tap test/*.js"
},
- "version": "7.1.2"
+ "version": "7.2.1"
}
diff --git a/node_modules/npm-registry-client/test/00-setup.js b/node_modules/npm-registry-client/test/00-setup.js
index 747768fb8..fb9585a42 100644
--- a/node_modules/npm-registry-client/test/00-setup.js
+++ b/node_modules/npm-registry-client/test/00-setup.js
@@ -1,8 +1,9 @@
-var tap = require('tap')
+var join = require('path').join
var rimraf = require('rimraf')
+var tap = require('tap')
tap.test('setup', function (t) {
- rimraf(__dirname + '/fixtures/cache', function (er) {
+ rimraf(join(__dirname, 'fixtures', 'cache'), function (er) {
if (er) throw er
t.pass('cache cleaned')
t.end()
diff --git a/node_modules/npm-registry-client/test/config-defaults.js b/node_modules/npm-registry-client/test/config-defaults.js
index a432da858..ca6983a1b 100644
--- a/node_modules/npm-registry-client/test/config-defaults.js
+++ b/node_modules/npm-registry-client/test/config-defaults.js
@@ -33,7 +33,7 @@ test('config defaults', function (t) {
})
test('missing HTTPS proxy defaults to HTTP proxy', function (t) {
- var client = common.freshClient({ proxy: { http: 'http://proxy.npm:8088/' }})
+ var client = common.freshClient({ proxy: { http: 'http://proxy.npm:8088/' } })
t.equal(client.config.proxy.http, 'http://proxy.npm:8088/', 'HTTP proxy set')
t.equal(client.config.proxy.http, client.config.proxy.https, 'HTTP === HTTPS')
diff --git a/node_modules/npm-registry-client/test/fetch-streaming.js b/node_modules/npm-registry-client/test/fetch-streaming.js
new file mode 100644
index 000000000..72aeea0be
--- /dev/null
+++ b/node_modules/npm-registry-client/test/fetch-streaming.js
@@ -0,0 +1,58 @@
+var test = require('tap').test
+var concat = require('concat-stream')
+
+var server = require('./lib/server.js')
+var common = require('./lib/common.js')
+var client = common.freshClient()
+
+var testData = JSON.stringify({test: true})
+var errorData = JSON.stringify({error: 'it went bad'})
+
+test('streaming fetch', function (t) {
+ server.expect('/test', function (req, res) {
+ t.equal(req.method, 'GET', 'got expected method')
+
+ res.writeHead(200, {
+ 'content-type': 'application/json'
+ })
+
+ res.end(testData)
+ })
+
+ server.expect('/error', function (req, res) {
+ t.equal(req.method, 'GET', 'got expected method')
+
+ res.writeHead(401, {
+ 'content-type': 'application/json'
+ })
+
+ res.end(errorData)
+ })
+
+ client.fetch(
+ 'http://localhost:1337/test',
+ { streaming: true },
+ function (er, res) {
+ t.ifError(er, 'loaded successfully')
+
+ var sink = concat(function (data) {
+ t.deepEqual(data.toString(), testData)
+ client.fetch(
+ 'http://localhost:1337/error',
+ { streaming: true },
+ function (er, res) {
+ t.ok(er, 'got an error')
+ server.close()
+ t.end()
+ }
+ )
+ })
+
+ res.on('error', function (error) {
+ t.ifError(error, 'no errors on stream')
+ })
+
+ res.pipe(sink)
+ }
+ )
+})
diff --git a/node_modules/npm-registry-client/test/initialize.js b/node_modules/npm-registry-client/test/initialize.js
index 3856b67b4..4a97bd5fd 100644
--- a/node_modules/npm-registry-client/test/initialize.js
+++ b/node_modules/npm-registry-client/test/initialize.js
@@ -83,7 +83,7 @@ test('referer set on client', function (t) {
})
test('initializing with proxy explicitly disabled', function (t) {
- var client = new Client({ proxy: { http: false }})
+ var client = new Client({ proxy: { http: false } })
var options = client.initialize(
'http://localhost:1337/',
'GET',
@@ -96,7 +96,7 @@ test('initializing with proxy explicitly disabled', function (t) {
})
test('initializing with proxy undefined', function (t) {
- var client = new Client({ proxy: { http: undefined }})
+ var client = new Client({ proxy: { http: undefined } })
var options = client.initialize(
'http://localhost:1337/',
'GET',
diff --git a/node_modules/npm-registry-client/test/lib/common.js b/node_modules/npm-registry-client/test/lib/common.js
index 78e543f69..ea48d3014 100644
--- a/node_modules/npm-registry-client/test/lib/common.js
+++ b/node_modules/npm-registry-client/test/lib/common.js
@@ -10,6 +10,14 @@ if (!global.setImmediate || !require('timers').setImmediate) {
}
}
+// See https://github.com/npm/npm-registry-client/pull/142 for background.
+// Note: `process.on('warning')` only works with Node >= 6.
+process.on('warning', function (warning) {
+ if (/Possible EventEmitter memory leak detected/.test(warning.message)) {
+ throw new Error('There should not be any EventEmitter memory leaks')
+ }
+})
+
module.exports = {
port: server.port,
registry: REGISTRY,
diff --git a/node_modules/npm-registry-client/test/zz-cleanup.js b/node_modules/npm-registry-client/test/zz-cleanup.js
index 35253c7ac..16e4ee8a1 100644
--- a/node_modules/npm-registry-client/test/zz-cleanup.js
+++ b/node_modules/npm-registry-client/test/zz-cleanup.js
@@ -1,8 +1,9 @@
-var tap = require('tap')
+var join = require('path').join
var rimraf = require('rimraf')
+var tap = require('tap')
tap.test('teardown', function (t) {
- rimraf(__dirname + '/fixtures/cache', function (er) {
+ rimraf(join(__dirname, 'fixtures', 'cache'), function (er) {
if (er) throw er
t.pass('cache cleaned')
t.end()