Template Upload
This commit is contained in:
1
node_modules/agent-base/.npmignore
generated
vendored
Normal file
1
node_modules/agent-base/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
/node_modules
|
8
node_modules/agent-base/.travis.yml
generated
vendored
Normal file
8
node_modules/agent-base/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
before_install:
|
||||
- '[ "${TRAVIS_NODE_VERSION}" != "0.8" ] || npm install -g npm@1.4.28'
|
||||
- npm install -g npm@latest
|
41
node_modules/agent-base/History.md
generated
vendored
Normal file
41
node_modules/agent-base/History.md
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
2.0.1 / 2015-09-10
|
||||
==================
|
||||
|
||||
* package: update "semver" to v5.0.1 for WebPack (#1, @vhpoet)
|
||||
|
||||
2.0.0 / 2015-07-10
|
||||
==================
|
||||
|
||||
* refactor to patch Node.js core for more consistent `opts` values
|
||||
* ensure that HTTP(s) default port numbers are always given
|
||||
* test: use ssl-cert-snakeoil SSL certs
|
||||
* test: add tests for arbitrary options
|
||||
* README: add API section
|
||||
* README: make the Agent HTTP/HTTPS generic in the example
|
||||
* README: use SVG for Travis-CI badge
|
||||
|
||||
1.0.2 / 2015-06-27
|
||||
==================
|
||||
|
||||
* agent: set `req._hadError` to true after emitting "error"
|
||||
* package: update "mocha" to v2
|
||||
* test: add artificial HTTP GET request test
|
||||
* test: add artificial data events test
|
||||
* test: fix artifical GET response test on node > v0.11.3
|
||||
* test: use a real timeout for the async error test
|
||||
|
||||
1.0.1 / 2013-09-09
|
||||
==================
|
||||
|
||||
* Fix passing an "error" object to the callback function on the first tick
|
||||
|
||||
1.0.0 / 2013-09-09
|
||||
==================
|
||||
|
||||
* New API: now you pass a callback function directly
|
||||
|
||||
0.0.1 / 2013-07-09
|
||||
==================
|
||||
|
||||
* Initial release
|
121
node_modules/agent-base/README.md
generated
vendored
Normal file
121
node_modules/agent-base/README.md
generated
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
agent-base
|
||||
==========
|
||||
### Turn a function into an `http.Agent` instance
|
||||
[](https://travis-ci.org/TooTallNate/node-agent-base)
|
||||
|
||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
||||
given callback function when sending outbound HTTP requests.
|
||||
|
||||
#### Some subclasses:
|
||||
|
||||
Here's some more interesting uses of `agent-base`.
|
||||
Send a pull request to list yours!
|
||||
|
||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS (v4a) proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install agent-base
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
||||
|
||||
``` js
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var agent = require('agent-base');
|
||||
|
||||
var endpoint = 'http://nodejs.org/api/';
|
||||
var opts = url.parse(endpoint);
|
||||
|
||||
// This is the important part!
|
||||
opts.agent = agent(function (req, opts, fn) {
|
||||
var socket;
|
||||
// `secureEndpoint` is true when using the https module
|
||||
if (opts.secureEndpoint) {
|
||||
socket = tls.connect(opts);
|
||||
} else {
|
||||
socket = net.connect(opts);
|
||||
}
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// Everything else works just like normal...
|
||||
http.get(opts, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
## Agent(Function callback) → http.Agent
|
||||
|
||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
||||
for every HTTP request that it is used as the `agent` for. The callback function
|
||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
||||
used as the underlying socket in the HTTP request.
|
||||
|
||||
The callback function should have the following signature:
|
||||
|
||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
||||
|
||||
The ClientRequest `req` can be accessed to read request headers and
|
||||
and the path, etc. The `options` object contains the options passed
|
||||
to the `http.request()`/`https.request()` function call, and is formatted
|
||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
||||
else you want a Socket to be created. Pass the created socket to
|
||||
the callback function `cb` once created, and the HTTP request will
|
||||
continue to proceed.
|
||||
|
||||
If the `https` module is used to invoke the HTTP request, then the
|
||||
`secureEndpoint` property on `options` will be set to `true`.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
101
node_modules/agent-base/agent.js
generated
vendored
Normal file
101
node_modules/agent-base/agent.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
require('./patch-core');
|
||||
var extend = require('extend');
|
||||
var inherits = require('util').inherits;
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = Agent;
|
||||
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function Agent (callback) {
|
||||
if (!(this instanceof Agent)) return new Agent(callback);
|
||||
if ('function' != typeof callback) throw new Error('Must pass a "callback function"');
|
||||
EventEmitter.call(this);
|
||||
this.callback = callback;
|
||||
}
|
||||
inherits(Agent, EventEmitter);
|
||||
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Agent.prototype.addRequest = function (req, host, port, localAddress) {
|
||||
var opts;
|
||||
if ('object' == typeof host) {
|
||||
// >= v0.11.x API
|
||||
opts = extend({}, req._options, host);
|
||||
} else {
|
||||
// <= v0.10.x API
|
||||
opts = extend({}, req._options, { host: host, port: port });
|
||||
if (null != localAddress) {
|
||||
opts.localAddress = localAddress;
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.host && opts.path) {
|
||||
// if both a `host` and `path` are specified then it's most likely the
|
||||
// result of a `url.parse()` call... we need to remove the `path` portion so
|
||||
// that `net.connect()` doesn't attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
|
||||
// set default `port` if none was explicitly specified
|
||||
if (null == opts.port) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
|
||||
// hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
|
||||
// clean up a bit of memory since we're no longer using this
|
||||
req._options = null;
|
||||
|
||||
// create the `net.Socket` instance
|
||||
var sync = true;
|
||||
this.callback(req, opts, function (err, socket) {
|
||||
function emitErr () {
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
}
|
||||
if (err) {
|
||||
if (sync) {
|
||||
// need to defer the "error" event, when sync, because by now the `req`
|
||||
// instance hasn't event been passed back to the user yet...
|
||||
process.nextTick(emitErr);
|
||||
} else {
|
||||
emitErr();
|
||||
}
|
||||
} else {
|
||||
req.onSocket(socket);
|
||||
}
|
||||
});
|
||||
sync = false;
|
||||
};
|
15
node_modules/agent-base/node_modules/.bin/semver
generated
vendored
Normal file
15
node_modules/agent-base/node_modules/.bin/semver
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
basedir=`dirname "$0"`
|
||||
|
||||
case `uname` in
|
||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
||||
esac
|
||||
|
||||
if [ -x "$basedir/node" ]; then
|
||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
else
|
||||
node "$basedir/../semver/bin/semver" "$@"
|
||||
ret=$?
|
||||
fi
|
||||
exit $ret
|
7
node_modules/agent-base/node_modules/.bin/semver.cmd
generated
vendored
Normal file
7
node_modules/agent-base/node_modules/.bin/semver.cmd
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
@IF EXIST "%~dp0\node.exe" (
|
||||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
|
||||
) ELSE (
|
||||
@SETLOCAL
|
||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
||||
node "%~dp0\..\semver\bin\semver" %*
|
||||
)
|
4
node_modules/agent-base/node_modules/semver/.npmignore
generated
vendored
Normal file
4
node_modules/agent-base/node_modules/semver/.npmignore
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
.nyc_output/
|
||||
nyc_output/
|
5
node_modules/agent-base/node_modules/semver/.travis.yml
generated
vendored
Normal file
5
node_modules/agent-base/node_modules/semver/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
- '0.12'
|
||||
- 'iojs'
|
15
node_modules/agent-base/node_modules/semver/LICENSE
generated
vendored
Normal file
15
node_modules/agent-base/node_modules/semver/LICENSE
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
303
node_modules/agent-base/node_modules/semver/README.md
generated
vendored
Normal file
303
node_modules/agent-base/node_modules/semver/README.md
generated
vendored
Normal file
@ -0,0 +1,303 @@
|
||||
semver(1) -- The semantic versioner for npm
|
||||
===========================================
|
||||
|
||||
## Usage
|
||||
|
||||
$ npm install semver
|
||||
|
||||
semver.valid('1.2.3') // '1.2.3'
|
||||
semver.valid('a.b.c') // null
|
||||
semver.clean(' =v1.2.3 ') // '1.2.3'
|
||||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
||||
semver.gt('1.2.3', '9.8.7') // false
|
||||
semver.lt('1.2.3', '9.8.7') // true
|
||||
|
||||
As a command-line utility:
|
||||
|
||||
$ semver -h
|
||||
|
||||
Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | --preid <identifier> | -l | -rv]
|
||||
Test if version(s) satisfy the supplied range(s), and sort them.
|
||||
|
||||
Multiple versions or ranges may be supplied, unless increment
|
||||
option is specified. In that case, only a single version may
|
||||
be used, and it is incremented by the specified level
|
||||
|
||||
Program exits successfully if any valid version satisfies
|
||||
all supplied ranges, and prints all satisfying versions.
|
||||
|
||||
If no versions are valid, or ranges are not satisfied,
|
||||
then exits failure.
|
||||
|
||||
Versions are printed in ascending order, so supplying
|
||||
multiple versions to the utility will just sort them.
|
||||
|
||||
## Versions
|
||||
|
||||
A "version" is described by the `v2.0.0` specification found at
|
||||
<http://semver.org/>.
|
||||
|
||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
||||
|
||||
## Ranges
|
||||
|
||||
A `version range` is a set of `comparators` which specify versions
|
||||
that satisfy the range.
|
||||
|
||||
A `comparator` is composed of an `operator` and a `version`. The set
|
||||
of primitive `operators` is:
|
||||
|
||||
* `<` Less than
|
||||
* `<=` Less than or equal to
|
||||
* `>` Greater than
|
||||
* `>=` Greater than or equal to
|
||||
* `=` Equal. If no operator is specified, then equality is assumed,
|
||||
so this operator is optional, but MAY be included.
|
||||
|
||||
For example, the comparator `>=1.2.7` would match the versions
|
||||
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
||||
or `1.1.0`.
|
||||
|
||||
Comparators can be joined by whitespace to form a `comparator set`,
|
||||
which is satisfied by the **intersection** of all of the comparators
|
||||
it includes.
|
||||
|
||||
A range is composed of one or more comparator sets, joined by `||`. A
|
||||
version matches a range if and only if every comparator in at least
|
||||
one of the `||`-separated comparator sets is satisfied by the version.
|
||||
|
||||
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
||||
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
||||
or `1.1.0`.
|
||||
|
||||
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
||||
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
||||
|
||||
### Prerelease Tags
|
||||
|
||||
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
||||
it will only be allowed to satisfy comparator sets if at least one
|
||||
comparator with the same `[major, minor, patch]` tuple also has a
|
||||
prerelease tag.
|
||||
|
||||
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
||||
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
||||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
||||
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
||||
range only accepts prerelease tags on the `1.2.3` version. The
|
||||
version `3.4.5` *would* satisfy the range, because it does not have a
|
||||
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
||||
|
||||
The purpose for this behavior is twofold. First, prerelease versions
|
||||
frequently are updated very quickly, and contain many breaking changes
|
||||
that are (by the author's design) not yet fit for public consumption.
|
||||
Therefore, by default, they are excluded from range matching
|
||||
semantics.
|
||||
|
||||
Second, a user who has opted into using a prerelease version has
|
||||
clearly indicated the intent to use *that specific* set of
|
||||
alpha/beta/rc versions. By including a prerelease tag in the range,
|
||||
the user is indicating that they are aware of the risk. However, it
|
||||
is still not appropriate to assume that they have opted into taking a
|
||||
similar risk on the *next* set of prerelease versions.
|
||||
|
||||
#### Prerelease Identifiers
|
||||
|
||||
The method `.inc` takes an additional `identifier` string argument that
|
||||
will append the value of the string as a prerelease identifier:
|
||||
|
||||
```javascript
|
||||
> semver.inc('1.2.3', 'pre', 'beta')
|
||||
'1.2.4-beta.0'
|
||||
```
|
||||
|
||||
command-line example:
|
||||
|
||||
```shell
|
||||
$ semver 1.2.3 -i prerelease --preid beta
|
||||
1.2.4-beta.0
|
||||
```
|
||||
|
||||
Which then can be used to increment further:
|
||||
|
||||
```shell
|
||||
$ semver 1.2.4-beta.0 -i prerelease
|
||||
1.2.4-beta.1
|
||||
```
|
||||
|
||||
### Advanced Range Syntax
|
||||
|
||||
Advanced range syntax desugars to primitive comparators in
|
||||
deterministic ways.
|
||||
|
||||
Advanced ranges may be combined in the same way as primitive
|
||||
comparators using white space or `||`.
|
||||
|
||||
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
||||
|
||||
Specifies an inclusive set.
|
||||
|
||||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the first version in the inclusive
|
||||
range, then the missing pieces are replaced with zeroes.
|
||||
|
||||
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
||||
|
||||
If a partial version is provided as the second version in the
|
||||
inclusive range, then all versions that start with the supplied parts
|
||||
of the tuple are accepted, but nothing that would be greater than the
|
||||
provided tuple parts.
|
||||
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
||||
|
||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
||||
|
||||
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
||||
numeric values in the `[major, minor, patch]` tuple.
|
||||
|
||||
* `*` := `>=0.0.0` (Any version satisfies)
|
||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
||||
|
||||
A partial version range is treated as an X-Range, so the special
|
||||
character is in fact optional.
|
||||
|
||||
* `""` (empty string) := `*` := `>=0.0.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
||||
|
||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||
|
||||
Allows patch-level changes if a minor version is specified on the
|
||||
comparator. Allows minor-level changes if not.
|
||||
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
|
||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
||||
|
||||
Allows changes that do not modify the left-most non-zero digit in the
|
||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
||||
minor updates for versions `1.0.0` and above, patch updates for
|
||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
||||
|
||||
Many authors treat a `0.x` version as if the `x` were the major
|
||||
"breaking-change" indicator.
|
||||
|
||||
Caret ranges are ideal when an author may make breaking changes
|
||||
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
||||
However, it presumes that there will *not* be breaking changes between
|
||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
||||
additive (but non-breaking), according to commonly observed practices.
|
||||
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
||||
|
||||
When parsing caret ranges, a missing `patch` value desugars to the
|
||||
number `0`, but will allow flexibility within that value, even if the
|
||||
major and minor versions are both `0`.
|
||||
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
||||
|
||||
A missing `minor` and `patch` values will desugar to zero, but also
|
||||
allow flexibility within those values, even if the major version is
|
||||
zero.
|
||||
|
||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
||||
|
||||
## Functions
|
||||
|
||||
All methods and classes take a final `loose` boolean argument that, if
|
||||
true, will be more forgiving about not-quite-valid semver strings.
|
||||
The resulting output will always be 100% strict, of course.
|
||||
|
||||
Strict-mode Comparators and Ranges will be strict about the SemVer
|
||||
strings that they parse.
|
||||
|
||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
||||
* `inc(v, release)`: Return the version incremented by the release
|
||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
||||
`prepatch`, or `prerelease`), or null if it's not valid
|
||||
* `premajor` in one call will bump the version up to the next major
|
||||
version and down to a prerelease of that major version.
|
||||
`preminor`, and `prepatch` work the same way.
|
||||
* If called from a non-prerelease version, the `prerelease` will work the
|
||||
same as `prepatch`. It increments the patch version, then makes a
|
||||
prerelease. If the input version is already a prerelease it simply
|
||||
increments it.
|
||||
* `major(v)`: Return the major version number.
|
||||
* `minor(v)`: Return the minor version number.
|
||||
* `patch(v)`: Return the patch version number.
|
||||
|
||||
### Comparison
|
||||
|
||||
* `gt(v1, v2)`: `v1 > v2`
|
||||
* `gte(v1, v2)`: `v1 >= v2`
|
||||
* `lt(v1, v2)`: `v1 < v2`
|
||||
* `lte(v1, v2)`: `v1 <= v2`
|
||||
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
||||
even if they're not the exact same string. You already know how to
|
||||
compare strings.
|
||||
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
||||
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
||||
the corresponding function above. `"==="` and `"!=="` do simple
|
||||
string comparison, but are included for completeness. Throws if an
|
||||
invalid comparison string is provided.
|
||||
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
||||
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
||||
in descending order when passed to `Array.sort()`.
|
||||
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
||||
or null if the versions are the same.
|
||||
|
||||
|
||||
### Ranges
|
||||
|
||||
* `validRange(range)`: Return the valid range or null if it's not valid
|
||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
||||
range.
|
||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
||||
that satisfies the range, or `null` if none of them do.
|
||||
* `gtr(version, range)`: Return `true` if version is greater than all the
|
||||
versions possible in the range.
|
||||
* `ltr(version, range)`: Return `true` if version is less than all the
|
||||
versions possible in the range.
|
||||
* `outside(version, range, hilo)`: Return true if the version is outside
|
||||
the bounds of the range in either the high or low direction. The
|
||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||
the function called by `gtr` and `ltr`.)
|
||||
|
||||
Note that, since ranges may be non-contiguous, a version might not be
|
||||
greater than a range, less than a range, *or* satisfy a range! For
|
||||
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
||||
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
||||
range (because `2.0.1` satisfies, which is higher), nor less than the
|
||||
range (since `1.2.8` satisfies, which is lower), and it also does not
|
||||
satisfy the range.
|
||||
|
||||
If you want to know if a version satisfies or does not satisfy a
|
||||
range, use the `satisfies(version, range)` function.
|
133
node_modules/agent-base/node_modules/semver/bin/semver
generated
vendored
Normal file
133
node_modules/agent-base/node_modules/semver/bin/semver
generated
vendored
Normal file
@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env node
|
||||
// Standalone semver comparison program.
|
||||
// Exits successfully and prints matching version(s) if
|
||||
// any supplied version is valid and passes all tests.
|
||||
|
||||
var argv = process.argv.slice(2)
|
||||
, versions = []
|
||||
, range = []
|
||||
, gt = []
|
||||
, lt = []
|
||||
, eq = []
|
||||
, inc = null
|
||||
, version = require("../package.json").version
|
||||
, loose = false
|
||||
, identifier = undefined
|
||||
, semver = require("../semver")
|
||||
, reverse = false
|
||||
|
||||
main()
|
||||
|
||||
function main () {
|
||||
if (!argv.length) return help()
|
||||
while (argv.length) {
|
||||
var a = argv.shift()
|
||||
var i = a.indexOf('=')
|
||||
if (i !== -1) {
|
||||
a = a.slice(0, i)
|
||||
argv.unshift(a.slice(i + 1))
|
||||
}
|
||||
switch (a) {
|
||||
case "-rv": case "-rev": case "--rev": case "--reverse":
|
||||
reverse = true
|
||||
break
|
||||
case "-l": case "--loose":
|
||||
loose = true
|
||||
break
|
||||
case "-v": case "--version":
|
||||
versions.push(argv.shift())
|
||||
break
|
||||
case "-i": case "--inc": case "--increment":
|
||||
switch (argv[0]) {
|
||||
case "major": case "minor": case "patch": case "prerelease":
|
||||
case "premajor": case "preminor": case "prepatch":
|
||||
inc = argv.shift()
|
||||
break
|
||||
default:
|
||||
inc = "patch"
|
||||
break
|
||||
}
|
||||
break
|
||||
case "--preid":
|
||||
identifier = argv.shift()
|
||||
break
|
||||
case "-r": case "--range":
|
||||
range.push(argv.shift())
|
||||
break
|
||||
case "-h": case "--help": case "-?":
|
||||
return help()
|
||||
default:
|
||||
versions.push(a)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
versions = versions.filter(function (v) {
|
||||
return semver.valid(v, loose)
|
||||
})
|
||||
if (!versions.length) return fail()
|
||||
if (inc && (versions.length !== 1 || range.length))
|
||||
return failInc()
|
||||
|
||||
for (var i = 0, l = range.length; i < l ; i ++) {
|
||||
versions = versions.filter(function (v) {
|
||||
return semver.satisfies(v, range[i], loose)
|
||||
})
|
||||
if (!versions.length) return fail()
|
||||
}
|
||||
return success(versions)
|
||||
}
|
||||
|
||||
function failInc () {
|
||||
console.error("--inc can only be used on a single version with no range")
|
||||
fail()
|
||||
}
|
||||
|
||||
function fail () { process.exit(1) }
|
||||
|
||||
function success () {
|
||||
var compare = reverse ? "rcompare" : "compare"
|
||||
versions.sort(function (a, b) {
|
||||
return semver[compare](a, b, loose)
|
||||
}).map(function (v) {
|
||||
return semver.clean(v, loose)
|
||||
}).map(function (v) {
|
||||
return inc ? semver.inc(v, inc, loose, identifier) : v
|
||||
}).forEach(function (v,i,_) { console.log(v) })
|
||||
}
|
||||
|
||||
function help () {
|
||||
console.log(["SemVer " + version
|
||||
,""
|
||||
,"A JavaScript implementation of the http://semver.org/ specification"
|
||||
,"Copyright Isaac Z. Schlueter"
|
||||
,""
|
||||
,"Usage: semver [options] <version> [<version> [...]]"
|
||||
,"Prints valid versions sorted by SemVer precedence"
|
||||
,""
|
||||
,"Options:"
|
||||
,"-r --range <range>"
|
||||
," Print versions that match the specified range."
|
||||
,""
|
||||
,"-i --increment [<level>]"
|
||||
," Increment a version by the specified level. Level can"
|
||||
," be one of: major, minor, patch, premajor, preminor,"
|
||||
," prepatch, or prerelease. Default level is 'patch'."
|
||||
," Only one version may be specified."
|
||||
,""
|
||||
,"--preid <identifier>"
|
||||
," Identifier to be used to prefix premajor, preminor,"
|
||||
," prepatch or prerelease version increments."
|
||||
,""
|
||||
,"-l --loose"
|
||||
," Interpret versions and ranges loosely"
|
||||
,""
|
||||
,"Program exits successfully if any valid version satisfies"
|
||||
,"all supplied ranges, and prints all satisfying versions."
|
||||
,""
|
||||
,"If no satisfying versions are found, then exits failure."
|
||||
,""
|
||||
,"Versions are printed in ascending order, so supplying"
|
||||
,"multiple versions to the utility will just sort them."
|
||||
].join("\n"))
|
||||
}
|
76
node_modules/agent-base/node_modules/semver/package.json
generated
vendored
Normal file
76
node_modules/agent-base/node_modules/semver/package.json
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"semver@~5.0.1",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\agent-base"
|
||||
]
|
||||
],
|
||||
"_from": "semver@>=5.0.1-0 <5.1.0-0",
|
||||
"_id": "semver@5.0.3",
|
||||
"_inCache": true,
|
||||
"_location": "/agent-base/semver",
|
||||
"_nodeVersion": "4.0.0",
|
||||
"_npmUser": {
|
||||
"email": "isaacs@npmjs.com",
|
||||
"name": "isaacs"
|
||||
},
|
||||
"_npmVersion": "3.3.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "semver",
|
||||
"raw": "semver@~5.0.1",
|
||||
"rawSpec": "~5.0.1",
|
||||
"scope": null,
|
||||
"spec": ">=5.0.1-0 <5.1.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/agent-base"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz",
|
||||
"_shasum": "77466de589cd5d3c95f138aa78bc569a3cb5d27a",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "semver@~5.0.1",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\agent-base",
|
||||
"bin": {
|
||||
"semver": "./bin/semver"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/node-semver/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"devDependencies": {
|
||||
"tap": "^1.3.4"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "77466de589cd5d3c95f138aa78bc569a3cb5d27a",
|
||||
"tarball": "https://registry.npmjs.org/semver/-/semver-5.0.3.tgz"
|
||||
},
|
||||
"gitHead": "5f89ecbe78145ad0b501cf6279f602a23c89738d",
|
||||
"homepage": "https://github.com/npm/node-semver#readme",
|
||||
"installable": true,
|
||||
"license": "ISC",
|
||||
"main": "semver.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "isaacs",
|
||||
"email": "isaacs@npmjs.com"
|
||||
},
|
||||
{
|
||||
"name": "othiym23",
|
||||
"email": "ogd@aoaioxxysz.net"
|
||||
}
|
||||
],
|
||||
"name": "semver",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/node-semver.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "5.0.3"
|
||||
}
|
1200
node_modules/agent-base/node_modules/semver/semver.js
generated
vendored
Normal file
1200
node_modules/agent-base/node_modules/semver/semver.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
node_modules/agent-base/node_modules/semver/test/big-numbers.js
generated
vendored
Normal file
31
node_modules/agent-base/node_modules/semver/test/big-numbers.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
var test = require('tap').test
|
||||
var semver = require('../')
|
||||
|
||||
test('long version is too long', function (t) {
|
||||
var v = '1.2.' + new Array(256).join('1')
|
||||
t.throws(function () {
|
||||
new semver.SemVer(v)
|
||||
})
|
||||
t.equal(semver.valid(v, false), null)
|
||||
t.equal(semver.valid(v, true), null)
|
||||
t.equal(semver.inc(v, 'patch'), null)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('big number is like too long version', function (t) {
|
||||
var v = '1.2.' + new Array(100).join('1')
|
||||
t.throws(function () {
|
||||
new semver.SemVer(v)
|
||||
})
|
||||
t.equal(semver.valid(v, false), null)
|
||||
t.equal(semver.valid(v, true), null)
|
||||
t.equal(semver.inc(v, 'patch'), null)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('parsing null does not throw', function (t) {
|
||||
t.equal(semver.parse(null), null)
|
||||
t.equal(semver.parse({}), null)
|
||||
t.equal(semver.parse(new semver.SemVer('1.2.3')).version, '1.2.3')
|
||||
t.end()
|
||||
})
|
29
node_modules/agent-base/node_modules/semver/test/clean.js
generated
vendored
Normal file
29
node_modules/agent-base/node_modules/semver/test/clean.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
var tap = require('tap');
|
||||
var test = tap.test;
|
||||
var semver = require('../semver.js');
|
||||
var clean = semver.clean;
|
||||
|
||||
test('\nclean tests', function(t) {
|
||||
// [range, version]
|
||||
// Version should be detectable despite extra characters
|
||||
[
|
||||
['1.2.3', '1.2.3'],
|
||||
[' 1.2.3 ', '1.2.3'],
|
||||
[' 1.2.3-4 ', '1.2.3-4'],
|
||||
[' 1.2.3-pre ', '1.2.3-pre'],
|
||||
[' =v1.2.3 ', '1.2.3'],
|
||||
['v1.2.3', '1.2.3'],
|
||||
[' v1.2.3 ', '1.2.3'],
|
||||
['\t1.2.3', '1.2.3'],
|
||||
['>1.2.3', null],
|
||||
['~1.2.3', null],
|
||||
['<=1.2.3', null],
|
||||
['1.2.x', null]
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var msg = 'clean(' + range + ') = ' + version;
|
||||
t.equal(clean(range), version, msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
173
node_modules/agent-base/node_modules/semver/test/gtr.js
generated
vendored
Normal file
173
node_modules/agent-base/node_modules/semver/test/gtr.js
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
var tap = require('tap');
|
||||
var test = tap.test;
|
||||
var semver = require('../semver.js');
|
||||
var gtr = semver.gtr;
|
||||
|
||||
test('\ngtr tests', function(t) {
|
||||
// [range, version, loose]
|
||||
// Version should be greater than range
|
||||
[
|
||||
['~1.2.2', '1.3.0'],
|
||||
['~0.6.1-1', '0.7.1-1'],
|
||||
['1.0.0 - 2.0.0', '2.0.1'],
|
||||
['1.0.0', '1.0.1-beta1'],
|
||||
['1.0.0', '2.0.0'],
|
||||
['<=2.0.0', '2.1.1'],
|
||||
['<=2.0.0', '3.2.9'],
|
||||
['<2.0.0', '2.0.0'],
|
||||
['0.1.20 || 1.2.4', '1.2.5'],
|
||||
['2.x.x', '3.0.0'],
|
||||
['1.2.x', '1.3.0'],
|
||||
['1.2.x || 2.x', '3.0.0'],
|
||||
['2.*.*', '5.0.1'],
|
||||
['1.2.*', '1.3.3'],
|
||||
['1.2.* || 2.*', '4.0.0'],
|
||||
['2', '3.0.0'],
|
||||
['2.3', '2.4.2'],
|
||||
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.5.5'],
|
||||
['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0
|
||||
['~1', '2.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '2.2.4'],
|
||||
['~> 1', '3.2.3'],
|
||||
['~1.0', '1.1.2'], // >=1.0.0 <1.1.0
|
||||
['~ 1.0', '1.1.0'],
|
||||
['<1.2', '1.2.0'],
|
||||
['< 1.2', '1.2.1'],
|
||||
['1', '2.0.0beta', true],
|
||||
['~v0.5.4-pre', '0.6.0'],
|
||||
['~v0.5.4-pre', '0.6.1-pre'],
|
||||
['=0.7.x', '0.8.0'],
|
||||
['=0.7.x', '0.8.0-asdf'],
|
||||
['<0.7.x', '0.7.0'],
|
||||
['~1.2.2', '1.3.0'],
|
||||
['1.0.0 - 2.0.0', '2.2.3'],
|
||||
['1.0.0', '1.0.1'],
|
||||
['<=2.0.0', '3.0.0'],
|
||||
['<=2.0.0', '2.9999.9999'],
|
||||
['<=2.0.0', '2.2.9'],
|
||||
['<2.0.0', '2.9999.9999'],
|
||||
['<2.0.0', '2.2.9'],
|
||||
['2.x.x', '3.1.3'],
|
||||
['1.2.x', '1.3.3'],
|
||||
['1.2.x || 2.x', '3.1.3'],
|
||||
['2.*.*', '3.1.3'],
|
||||
['1.2.*', '1.3.3'],
|
||||
['1.2.* || 2.*', '3.1.3'],
|
||||
['2', '3.1.2'],
|
||||
['2.3', '2.4.1'],
|
||||
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
|
||||
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
|
||||
['~1', '2.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '2.2.3'],
|
||||
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
|
||||
['<1', '1.0.0'],
|
||||
['1', '2.0.0beta', true],
|
||||
['<1', '1.0.0beta', true],
|
||||
['< 1', '1.0.0beta', true],
|
||||
['=0.7.x', '0.8.2'],
|
||||
['<0.7.x', '0.7.2']
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = 'gtr(' + version + ', ' + range + ', ' + loose + ')';
|
||||
t.ok(gtr(version, range, loose), msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nnegative gtr tests', function(t) {
|
||||
// [range, version, loose]
|
||||
// Version should NOT be greater than range
|
||||
[
|
||||
['~0.6.1-1', '0.6.1-1'],
|
||||
['1.0.0 - 2.0.0', '1.2.3'],
|
||||
['1.0.0 - 2.0.0', '0.9.9'],
|
||||
['1.0.0', '1.0.0'],
|
||||
['>=*', '0.2.4'],
|
||||
['', '1.0.0', true],
|
||||
['*', '1.2.3'],
|
||||
['*', 'v1.2.3-foo'],
|
||||
['>=1.0.0', '1.0.0'],
|
||||
['>=1.0.0', '1.0.1'],
|
||||
['>=1.0.0', '1.1.0'],
|
||||
['>1.0.0', '1.0.1'],
|
||||
['>1.0.0', '1.1.0'],
|
||||
['<=2.0.0', '2.0.0'],
|
||||
['<=2.0.0', '1.9999.9999'],
|
||||
['<=2.0.0', '0.2.9'],
|
||||
['<2.0.0', '1.9999.9999'],
|
||||
['<2.0.0', '0.2.9'],
|
||||
['>= 1.0.0', '1.0.0'],
|
||||
['>= 1.0.0', '1.0.1'],
|
||||
['>= 1.0.0', '1.1.0'],
|
||||
['> 1.0.0', '1.0.1'],
|
||||
['> 1.0.0', '1.1.0'],
|
||||
['<= 2.0.0', '2.0.0'],
|
||||
['<= 2.0.0', '1.9999.9999'],
|
||||
['<= 2.0.0', '0.2.9'],
|
||||
['< 2.0.0', '1.9999.9999'],
|
||||
['<\t2.0.0', '0.2.9'],
|
||||
['>=0.1.97', 'v0.1.97'],
|
||||
['>=0.1.97', '0.1.97'],
|
||||
['0.1.20 || 1.2.4', '1.2.4'],
|
||||
['0.1.20 || >1.2.4', '1.2.4'],
|
||||
['0.1.20 || 1.2.4', '1.2.3'],
|
||||
['0.1.20 || 1.2.4', '0.1.20'],
|
||||
['>=0.2.3 || <0.0.1', '0.0.0'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.3'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.4'],
|
||||
['||', '1.3.4'],
|
||||
['2.x.x', '2.1.3'],
|
||||
['1.2.x', '1.2.3'],
|
||||
['1.2.x || 2.x', '2.1.3'],
|
||||
['1.2.x || 2.x', '1.2.3'],
|
||||
['x', '1.2.3'],
|
||||
['2.*.*', '2.1.3'],
|
||||
['1.2.*', '1.2.3'],
|
||||
['1.2.* || 2.*', '2.1.3'],
|
||||
['1.2.* || 2.*', '1.2.3'],
|
||||
['1.2.* || 2.*', '1.2.3'],
|
||||
['*', '1.2.3'],
|
||||
['2', '2.1.2'],
|
||||
['2.3', '2.3.1'],
|
||||
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.4.5'],
|
||||
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
|
||||
['~1', '1.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '1.2.3'],
|
||||
['~> 1', '1.2.3'],
|
||||
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
|
||||
['~ 1.0', '1.0.2'],
|
||||
['>=1', '1.0.0'],
|
||||
['>= 1', '1.0.0'],
|
||||
['<1.2', '1.1.1'],
|
||||
['< 1.2', '1.1.1'],
|
||||
['1', '1.0.0beta', true],
|
||||
['~v0.5.4-pre', '0.5.5'],
|
||||
['~v0.5.4-pre', '0.5.4'],
|
||||
['=0.7.x', '0.7.2'],
|
||||
['>=0.7.x', '0.7.2'],
|
||||
['=0.7.x', '0.7.0-asdf'],
|
||||
['>=0.7.x', '0.7.0-asdf'],
|
||||
['<=0.7.x', '0.6.2'],
|
||||
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
|
||||
['>=0.2.3 <=0.2.4', '0.2.4'],
|
||||
['1.0.0 - 2.0.0', '2.0.0'],
|
||||
['^1', '0.0.0-0'],
|
||||
['^3.0.0', '2.0.0'],
|
||||
['^1.0.0 || ~2.0.1', '2.0.0'],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
|
||||
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0']
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = '!gtr(' + version + ', ' + range + ', ' + loose + ')';
|
||||
t.notOk(gtr(version, range, loose), msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
698
node_modules/agent-base/node_modules/semver/test/index.js
generated
vendored
Normal file
698
node_modules/agent-base/node_modules/semver/test/index.js
generated
vendored
Normal file
@ -0,0 +1,698 @@
|
||||
'use strict';
|
||||
|
||||
var tap = require('tap');
|
||||
var test = tap.test;
|
||||
var semver = require('../semver.js');
|
||||
var eq = semver.eq;
|
||||
var gt = semver.gt;
|
||||
var lt = semver.lt;
|
||||
var neq = semver.neq;
|
||||
var cmp = semver.cmp;
|
||||
var gte = semver.gte;
|
||||
var lte = semver.lte;
|
||||
var satisfies = semver.satisfies;
|
||||
var validRange = semver.validRange;
|
||||
var inc = semver.inc;
|
||||
var diff = semver.diff;
|
||||
var replaceStars = semver.replaceStars;
|
||||
var toComparators = semver.toComparators;
|
||||
var SemVer = semver.SemVer;
|
||||
var Range = semver.Range;
|
||||
|
||||
test('\ncomparison tests', function(t) {
|
||||
// [version1, version2]
|
||||
// version1 should be greater than version2
|
||||
[['0.0.0', '0.0.0-foo'],
|
||||
['0.0.1', '0.0.0'],
|
||||
['1.0.0', '0.9.9'],
|
||||
['0.10.0', '0.9.0'],
|
||||
['0.99.0', '0.10.0'],
|
||||
['2.0.0', '1.2.3'],
|
||||
['v0.0.0', '0.0.0-foo', true],
|
||||
['v0.0.1', '0.0.0', true],
|
||||
['v1.0.0', '0.9.9', true],
|
||||
['v0.10.0', '0.9.0', true],
|
||||
['v0.99.0', '0.10.0', true],
|
||||
['v2.0.0', '1.2.3', true],
|
||||
['0.0.0', 'v0.0.0-foo', true],
|
||||
['0.0.1', 'v0.0.0', true],
|
||||
['1.0.0', 'v0.9.9', true],
|
||||
['0.10.0', 'v0.9.0', true],
|
||||
['0.99.0', 'v0.10.0', true],
|
||||
['2.0.0', 'v1.2.3', true],
|
||||
['1.2.3', '1.2.3-asdf'],
|
||||
['1.2.3', '1.2.3-4'],
|
||||
['1.2.3', '1.2.3-4-foo'],
|
||||
['1.2.3-5-foo', '1.2.3-5'],
|
||||
['1.2.3-5', '1.2.3-4'],
|
||||
['1.2.3-5-foo', '1.2.3-5-Foo'],
|
||||
['3.0.0', '2.7.2+asdf'],
|
||||
['1.2.3-a.10', '1.2.3-a.5'],
|
||||
['1.2.3-a.b', '1.2.3-a.5'],
|
||||
['1.2.3-a.b', '1.2.3-a'],
|
||||
['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'],
|
||||
['1.2.3-r2', '1.2.3-r100'],
|
||||
['1.2.3-r100', '1.2.3-R2']
|
||||
].forEach(function(v) {
|
||||
var v0 = v[0];
|
||||
var v1 = v[1];
|
||||
var loose = v[2];
|
||||
t.ok(gt(v0, v1, loose), "gt('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(lt(v1, v0, loose), "lt('" + v1 + "', '" + v0 + "')");
|
||||
t.ok(!gt(v1, v0, loose), "!gt('" + v1 + "', '" + v0 + "')");
|
||||
t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(eq(v0, v0, loose), "eq('" + v0 + "', '" + v0 + "')");
|
||||
t.ok(eq(v1, v1, loose), "eq('" + v1 + "', '" + v1 + "')");
|
||||
t.ok(neq(v0, v1, loose), "neq('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(cmp(v1, '==', v1, loose), "cmp('" + v1 + "' == '" + v1 + "')");
|
||||
t.ok(cmp(v0, '>=', v1, loose), "cmp('" + v0 + "' >= '" + v1 + "')");
|
||||
t.ok(cmp(v1, '<=', v0, loose), "cmp('" + v1 + "' <= '" + v0 + "')");
|
||||
t.ok(cmp(v0, '!=', v1, loose), "cmp('" + v0 + "' != '" + v1 + "')");
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nequality tests', function(t) {
|
||||
// [version1, version2]
|
||||
// version1 should be equivalent to version2
|
||||
[['1.2.3', 'v1.2.3', true],
|
||||
['1.2.3', '=1.2.3', true],
|
||||
['1.2.3', 'v 1.2.3', true],
|
||||
['1.2.3', '= 1.2.3', true],
|
||||
['1.2.3', ' v1.2.3', true],
|
||||
['1.2.3', ' =1.2.3', true],
|
||||
['1.2.3', ' v 1.2.3', true],
|
||||
['1.2.3', ' = 1.2.3', true],
|
||||
['1.2.3-0', 'v1.2.3-0', true],
|
||||
['1.2.3-0', '=1.2.3-0', true],
|
||||
['1.2.3-0', 'v 1.2.3-0', true],
|
||||
['1.2.3-0', '= 1.2.3-0', true],
|
||||
['1.2.3-0', ' v1.2.3-0', true],
|
||||
['1.2.3-0', ' =1.2.3-0', true],
|
||||
['1.2.3-0', ' v 1.2.3-0', true],
|
||||
['1.2.3-0', ' = 1.2.3-0', true],
|
||||
['1.2.3-1', 'v1.2.3-1', true],
|
||||
['1.2.3-1', '=1.2.3-1', true],
|
||||
['1.2.3-1', 'v 1.2.3-1', true],
|
||||
['1.2.3-1', '= 1.2.3-1', true],
|
||||
['1.2.3-1', ' v1.2.3-1', true],
|
||||
['1.2.3-1', ' =1.2.3-1', true],
|
||||
['1.2.3-1', ' v 1.2.3-1', true],
|
||||
['1.2.3-1', ' = 1.2.3-1', true],
|
||||
['1.2.3-beta', 'v1.2.3-beta', true],
|
||||
['1.2.3-beta', '=1.2.3-beta', true],
|
||||
['1.2.3-beta', 'v 1.2.3-beta', true],
|
||||
['1.2.3-beta', '= 1.2.3-beta', true],
|
||||
['1.2.3-beta', ' v1.2.3-beta', true],
|
||||
['1.2.3-beta', ' =1.2.3-beta', true],
|
||||
['1.2.3-beta', ' v 1.2.3-beta', true],
|
||||
['1.2.3-beta', ' = 1.2.3-beta', true],
|
||||
['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true],
|
||||
['1.2.3+build', ' = 1.2.3+otherbuild', true],
|
||||
['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
|
||||
['1.2.3+build', '1.2.3+otherbuild'],
|
||||
[' v1.2.3+build', '1.2.3+otherbuild']
|
||||
].forEach(function(v) {
|
||||
var v0 = v[0];
|
||||
var v1 = v[1];
|
||||
var loose = v[2];
|
||||
t.ok(eq(v0, v1, loose), "eq('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(!neq(v0, v1, loose), "!neq('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(cmp(v0, '==', v1, loose), 'cmp(' + v0 + '==' + v1 + ')');
|
||||
t.ok(!cmp(v0, '!=', v1, loose), '!cmp(' + v0 + '!=' + v1 + ')');
|
||||
t.ok(!cmp(v0, '===', v1, loose), '!cmp(' + v0 + '===' + v1 + ')');
|
||||
t.ok(cmp(v0, '!==', v1, loose), 'cmp(' + v0 + '!==' + v1 + ')');
|
||||
t.ok(!gt(v0, v1, loose), "!gt('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(gte(v0, v1, loose), "gte('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
|
||||
t.ok(lte(v0, v1, loose), "lte('" + v0 + "', '" + v1 + "')");
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('\nrange tests', function(t) {
|
||||
// [range, version]
|
||||
// version should be included by range
|
||||
[['1.0.0 - 2.0.0', '1.2.3'],
|
||||
['^1.2.3+build', '1.2.3'],
|
||||
['^1.2.3+build', '1.3.0'],
|
||||
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'],
|
||||
['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true],
|
||||
['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
|
||||
['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
|
||||
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'],
|
||||
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'],
|
||||
['1.2.3+asdf - 2.4.3+asdf', '1.2.3'],
|
||||
['1.0.0', '1.0.0'],
|
||||
['>=*', '0.2.4'],
|
||||
['', '1.0.0'],
|
||||
['*', '1.2.3'],
|
||||
['*', 'v1.2.3', true],
|
||||
['>=1.0.0', '1.0.0'],
|
||||
['>=1.0.0', '1.0.1'],
|
||||
['>=1.0.0', '1.1.0'],
|
||||
['>1.0.0', '1.0.1'],
|
||||
['>1.0.0', '1.1.0'],
|
||||
['<=2.0.0', '2.0.0'],
|
||||
['<=2.0.0', '1.9999.9999'],
|
||||
['<=2.0.0', '0.2.9'],
|
||||
['<2.0.0', '1.9999.9999'],
|
||||
['<2.0.0', '0.2.9'],
|
||||
['>= 1.0.0', '1.0.0'],
|
||||
['>= 1.0.0', '1.0.1'],
|
||||
['>= 1.0.0', '1.1.0'],
|
||||
['> 1.0.0', '1.0.1'],
|
||||
['> 1.0.0', '1.1.0'],
|
||||
['<= 2.0.0', '2.0.0'],
|
||||
['<= 2.0.0', '1.9999.9999'],
|
||||
['<= 2.0.0', '0.2.9'],
|
||||
['< 2.0.0', '1.9999.9999'],
|
||||
['<\t2.0.0', '0.2.9'],
|
||||
['>=0.1.97', 'v0.1.97', true],
|
||||
['>=0.1.97', '0.1.97'],
|
||||
['0.1.20 || 1.2.4', '1.2.4'],
|
||||
['>=0.2.3 || <0.0.1', '0.0.0'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.3'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.4'],
|
||||
['||', '1.3.4'],
|
||||
['2.x.x', '2.1.3'],
|
||||
['1.2.x', '1.2.3'],
|
||||
['1.2.x || 2.x', '2.1.3'],
|
||||
['1.2.x || 2.x', '1.2.3'],
|
||||
['x', '1.2.3'],
|
||||
['2.*.*', '2.1.3'],
|
||||
['1.2.*', '1.2.3'],
|
||||
['1.2.* || 2.*', '2.1.3'],
|
||||
['1.2.* || 2.*', '1.2.3'],
|
||||
['*', '1.2.3'],
|
||||
['2', '2.1.2'],
|
||||
['2.3', '2.3.1'],
|
||||
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.4.5'],
|
||||
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0,
|
||||
['~1', '1.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '1.2.3'],
|
||||
['~> 1', '1.2.3'],
|
||||
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0,
|
||||
['~ 1.0', '1.0.2'],
|
||||
['~ 1.0.3', '1.0.12'],
|
||||
['>=1', '1.0.0'],
|
||||
['>= 1', '1.0.0'],
|
||||
['<1.2', '1.1.1'],
|
||||
['< 1.2', '1.1.1'],
|
||||
['~v0.5.4-pre', '0.5.5'],
|
||||
['~v0.5.4-pre', '0.5.4'],
|
||||
['=0.7.x', '0.7.2'],
|
||||
['<=0.7.x', '0.7.2'],
|
||||
['>=0.7.x', '0.7.2'],
|
||||
['<=0.7.x', '0.6.2'],
|
||||
['~1.2.1 >=1.2.3', '1.2.3'],
|
||||
['~1.2.1 =1.2.3', '1.2.3'],
|
||||
['~1.2.1 1.2.3', '1.2.3'],
|
||||
['~1.2.1 >=1.2.3 1.2.3', '1.2.3'],
|
||||
['~1.2.1 1.2.3 >=1.2.3', '1.2.3'],
|
||||
['~1.2.1 1.2.3', '1.2.3'],
|
||||
['>=1.2.1 1.2.3', '1.2.3'],
|
||||
['1.2.3 >=1.2.1', '1.2.3'],
|
||||
['>=1.2.3 >=1.2.1', '1.2.3'],
|
||||
['>=1.2.1 >=1.2.3', '1.2.3'],
|
||||
['>=1.2', '1.2.8'],
|
||||
['^1.2.3', '1.8.1'],
|
||||
['^0.1.2', '0.1.2'],
|
||||
['^0.1', '0.1.2'],
|
||||
['^1.2', '1.4.2'],
|
||||
['^1.2 ^1', '1.4.2'],
|
||||
['^1.2.3-alpha', '1.2.3-pre'],
|
||||
['^1.2.0-alpha', '1.2.0-pre'],
|
||||
['^0.0.1-alpha', '0.0.1-beta']
|
||||
].forEach(function(v) {
|
||||
var range = v[0];
|
||||
var ver = v[1];
|
||||
var loose = v[2];
|
||||
t.ok(satisfies(ver, range, loose), range + ' satisfied by ' + ver);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nnegative range tests', function(t) {
|
||||
// [range, version]
|
||||
// version should not be included by range
|
||||
[['1.0.0 - 2.0.0', '2.2.3'],
|
||||
['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'],
|
||||
['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'],
|
||||
['^1.2.3+build', '2.0.0'],
|
||||
['^1.2.3+build', '1.2.0'],
|
||||
['^1.2.3', '1.2.3-pre'],
|
||||
['^1.2', '1.2.0-pre'],
|
||||
['>1.2', '1.3.0-beta'],
|
||||
['<=1.2.3', '1.2.3-beta'],
|
||||
['^1.2.3', '1.2.3-beta'],
|
||||
['=0.7.x', '0.7.0-asdf'],
|
||||
['>=0.7.x', '0.7.0-asdf'],
|
||||
['1', '1.0.0beta', true],
|
||||
['<1', '1.0.0beta', true],
|
||||
['< 1', '1.0.0beta', true],
|
||||
['1.0.0', '1.0.1'],
|
||||
['>=1.0.0', '0.0.0'],
|
||||
['>=1.0.0', '0.0.1'],
|
||||
['>=1.0.0', '0.1.0'],
|
||||
['>1.0.0', '0.0.1'],
|
||||
['>1.0.0', '0.1.0'],
|
||||
['<=2.0.0', '3.0.0'],
|
||||
['<=2.0.0', '2.9999.9999'],
|
||||
['<=2.0.0', '2.2.9'],
|
||||
['<2.0.0', '2.9999.9999'],
|
||||
['<2.0.0', '2.2.9'],
|
||||
['>=0.1.97', 'v0.1.93', true],
|
||||
['>=0.1.97', '0.1.93'],
|
||||
['0.1.20 || 1.2.4', '1.2.3'],
|
||||
['>=0.2.3 || <0.0.1', '0.0.3'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.2'],
|
||||
['2.x.x', '1.1.3'],
|
||||
['2.x.x', '3.1.3'],
|
||||
['1.2.x', '1.3.3'],
|
||||
['1.2.x || 2.x', '3.1.3'],
|
||||
['1.2.x || 2.x', '1.1.3'],
|
||||
['2.*.*', '1.1.3'],
|
||||
['2.*.*', '3.1.3'],
|
||||
['1.2.*', '1.3.3'],
|
||||
['1.2.* || 2.*', '3.1.3'],
|
||||
['1.2.* || 2.*', '1.1.3'],
|
||||
['2', '1.1.2'],
|
||||
['2.3', '2.4.1'],
|
||||
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.3.9'],
|
||||
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
|
||||
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
|
||||
['~1', '0.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '2.2.3'],
|
||||
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
|
||||
['<1', '1.0.0'],
|
||||
['>=1.2', '1.1.1'],
|
||||
['1', '2.0.0beta', true],
|
||||
['~v0.5.4-beta', '0.5.4-alpha'],
|
||||
['=0.7.x', '0.8.2'],
|
||||
['>=0.7.x', '0.6.2'],
|
||||
['<0.7.x', '0.7.2'],
|
||||
['<1.2.3', '1.2.3-beta'],
|
||||
['=1.2.3', '1.2.3-beta'],
|
||||
['>1.2', '1.2.8'],
|
||||
['^1.2.3', '2.0.0-alpha'],
|
||||
['^1.2.3', '1.2.2'],
|
||||
['^1.2', '1.1.9'],
|
||||
['*', 'v1.2.3-foo', true],
|
||||
// invalid ranges never satisfied!
|
||||
['blerg', '1.2.3'],
|
||||
['git+https://user:password0123@github.com/foo', '123.0.0', true],
|
||||
['^1.2.3', '2.0.0-pre']
|
||||
].forEach(function(v) {
|
||||
var range = v[0];
|
||||
var ver = v[1];
|
||||
var loose = v[2];
|
||||
var found = satisfies(ver, range, loose);
|
||||
t.ok(!found, ver + ' not satisfied by ' + range);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nincrement versions test', function(t) {
|
||||
// [version, inc, result, identifier]
|
||||
// inc(version, inc) -> result
|
||||
[['1.2.3', 'major', '2.0.0'],
|
||||
['1.2.3', 'minor', '1.3.0'],
|
||||
['1.2.3', 'patch', '1.2.4'],
|
||||
['1.2.3tag', 'major', '2.0.0', true],
|
||||
['1.2.3-tag', 'major', '2.0.0'],
|
||||
['1.2.3', 'fake', null],
|
||||
['1.2.0-0', 'patch', '1.2.0'],
|
||||
['fake', 'major', null],
|
||||
['1.2.3-4', 'major', '2.0.0'],
|
||||
['1.2.3-4', 'minor', '1.3.0'],
|
||||
['1.2.3-4', 'patch', '1.2.3'],
|
||||
['1.2.3-alpha.0.beta', 'major', '2.0.0'],
|
||||
['1.2.3-alpha.0.beta', 'minor', '1.3.0'],
|
||||
['1.2.3-alpha.0.beta', 'patch', '1.2.3'],
|
||||
['1.2.4', 'prerelease', '1.2.5-0'],
|
||||
['1.2.3-0', 'prerelease', '1.2.3-1'],
|
||||
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'],
|
||||
['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'],
|
||||
['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'],
|
||||
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'],
|
||||
['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'],
|
||||
['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'],
|
||||
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'],
|
||||
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'],
|
||||
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'],
|
||||
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'],
|
||||
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'],
|
||||
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'],
|
||||
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'],
|
||||
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'],
|
||||
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'],
|
||||
['1.2.0', 'prepatch', '1.2.1-0'],
|
||||
['1.2.0-1', 'prepatch', '1.2.1-0'],
|
||||
['1.2.0', 'preminor', '1.3.0-0'],
|
||||
['1.2.3-1', 'preminor', '1.3.0-0'],
|
||||
['1.2.0', 'premajor', '2.0.0-0'],
|
||||
['1.2.3-1', 'premajor', '2.0.0-0'],
|
||||
['1.2.0-1', 'minor', '1.2.0'],
|
||||
['1.0.0-1', 'major', '1.0.0'],
|
||||
|
||||
['1.2.3', 'major', '2.0.0', false, 'dev'],
|
||||
['1.2.3', 'minor', '1.3.0', false, 'dev'],
|
||||
['1.2.3', 'patch', '1.2.4', false, 'dev'],
|
||||
['1.2.3tag', 'major', '2.0.0', true, 'dev'],
|
||||
['1.2.3-tag', 'major', '2.0.0', false, 'dev'],
|
||||
['1.2.3', 'fake', null, false, 'dev'],
|
||||
['1.2.0-0', 'patch', '1.2.0', false, 'dev'],
|
||||
['fake', 'major', null, false, 'dev'],
|
||||
['1.2.3-4', 'major', '2.0.0', false, 'dev'],
|
||||
['1.2.3-4', 'minor', '1.3.0', false, 'dev'],
|
||||
['1.2.3-4', 'patch', '1.2.3', false, 'dev'],
|
||||
['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'],
|
||||
['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'],
|
||||
['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'],
|
||||
['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'],
|
||||
['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'],
|
||||
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'],
|
||||
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'],
|
||||
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'],
|
||||
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
|
||||
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'],
|
||||
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'],
|
||||
['1.2.0', 'prepatch', '1.2.1-dev.0', false, 'dev'],
|
||||
['1.2.0-1', 'prepatch', '1.2.1-dev.0', false, 'dev'],
|
||||
['1.2.0', 'preminor', '1.3.0-dev.0', false, 'dev'],
|
||||
['1.2.3-1', 'preminor', '1.3.0-dev.0', false, 'dev'],
|
||||
['1.2.0', 'premajor', '2.0.0-dev.0', false, 'dev'],
|
||||
['1.2.3-1', 'premajor', '2.0.0-dev.0', false, 'dev'],
|
||||
['1.2.0-1', 'minor', '1.2.0', false, 'dev'],
|
||||
['1.0.0-1', 'major', '1.0.0', false, 'dev'],
|
||||
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev']
|
||||
|
||||
].forEach(function(v) {
|
||||
var pre = v[0];
|
||||
var what = v[1];
|
||||
var wanted = v[2];
|
||||
var loose = v[3];
|
||||
var id = v[4];
|
||||
var found = inc(pre, what, loose, id);
|
||||
var cmd = 'inc(' + pre + ', ' + what + ', ' + id + ')';
|
||||
t.equal(found, wanted, cmd + ' === ' + wanted);
|
||||
|
||||
var parsed = semver.parse(pre, loose);
|
||||
if (wanted) {
|
||||
parsed.inc(what, id);
|
||||
t.equal(parsed.version, wanted, cmd + ' object version updated');
|
||||
t.equal(parsed.raw, wanted, cmd + ' object raw field updated');
|
||||
} else if (parsed) {
|
||||
t.throws(function () {
|
||||
parsed.inc(what, id)
|
||||
})
|
||||
} else {
|
||||
t.equal(parsed, null)
|
||||
}
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\ndiff versions test', function(t) {
|
||||
// [version1, version2, result]
|
||||
// diff(version1, version2) -> result
|
||||
[['1.2.3', '0.2.3', 'major'],
|
||||
['1.4.5', '0.2.3', 'major'],
|
||||
['1.2.3', '2.0.0-pre', 'premajor'],
|
||||
['1.2.3', '1.3.3', 'minor'],
|
||||
['1.0.1', '1.1.0-pre', 'preminor'],
|
||||
['1.2.3', '1.2.4', 'patch'],
|
||||
['1.2.3', '1.2.4-pre', 'prepatch'],
|
||||
['0.0.1', '0.0.1-pre', 'prerelease'],
|
||||
['0.0.1', '0.0.1-pre-2', 'prerelease'],
|
||||
['1.1.0', '1.1.0-pre', 'prerelease'],
|
||||
['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'],
|
||||
['1.0.0', '1.0.0', null]
|
||||
|
||||
].forEach(function(v) {
|
||||
var version1 = v[0];
|
||||
var version2 = v[1];
|
||||
var wanted = v[2];
|
||||
var found = diff(version1, version2);
|
||||
var cmd = 'diff(' + version1 + ', ' + version2 + ')';
|
||||
t.equal(found, wanted, cmd + ' === ' + wanted);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nvalid range test', function(t) {
|
||||
// [range, result]
|
||||
// validRange(range) -> result
|
||||
// translate ranges into their canonical form
|
||||
[['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'],
|
||||
['1.0.0', '1.0.0'],
|
||||
['>=*', '*'],
|
||||
['', '*'],
|
||||
['*', '*'],
|
||||
['*', '*'],
|
||||
['>=1.0.0', '>=1.0.0'],
|
||||
['>1.0.0', '>1.0.0'],
|
||||
['<=2.0.0', '<=2.0.0'],
|
||||
['1', '>=1.0.0 <2.0.0'],
|
||||
['<=2.0.0', '<=2.0.0'],
|
||||
['<=2.0.0', '<=2.0.0'],
|
||||
['<2.0.0', '<2.0.0'],
|
||||
['<2.0.0', '<2.0.0'],
|
||||
['>= 1.0.0', '>=1.0.0'],
|
||||
['>= 1.0.0', '>=1.0.0'],
|
||||
['>= 1.0.0', '>=1.0.0'],
|
||||
['> 1.0.0', '>1.0.0'],
|
||||
['> 1.0.0', '>1.0.0'],
|
||||
['<= 2.0.0', '<=2.0.0'],
|
||||
['<= 2.0.0', '<=2.0.0'],
|
||||
['<= 2.0.0', '<=2.0.0'],
|
||||
['< 2.0.0', '<2.0.0'],
|
||||
['< 2.0.0', '<2.0.0'],
|
||||
['>=0.1.97', '>=0.1.97'],
|
||||
['>=0.1.97', '>=0.1.97'],
|
||||
['0.1.20 || 1.2.4', '0.1.20||1.2.4'],
|
||||
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
|
||||
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
|
||||
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
|
||||
['||', '||'],
|
||||
['2.x.x', '>=2.0.0 <3.0.0'],
|
||||
['1.2.x', '>=1.2.0 <1.3.0'],
|
||||
['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
|
||||
['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
|
||||
['x', '*'],
|
||||
['2.*.*', '>=2.0.0 <3.0.0'],
|
||||
['1.2.*', '>=1.2.0 <1.3.0'],
|
||||
['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
|
||||
['*', '*'],
|
||||
['2', '>=2.0.0 <3.0.0'],
|
||||
['2.3', '>=2.3.0 <2.4.0'],
|
||||
['~2.4', '>=2.4.0 <2.5.0'],
|
||||
['~2.4', '>=2.4.0 <2.5.0'],
|
||||
['~>3.2.1', '>=3.2.1 <3.3.0'],
|
||||
['~1', '>=1.0.0 <2.0.0'],
|
||||
['~>1', '>=1.0.0 <2.0.0'],
|
||||
['~> 1', '>=1.0.0 <2.0.0'],
|
||||
['~1.0', '>=1.0.0 <1.1.0'],
|
||||
['~ 1.0', '>=1.0.0 <1.1.0'],
|
||||
['^0', '>=0.0.0 <1.0.0'],
|
||||
['^ 1', '>=1.0.0 <2.0.0'],
|
||||
['^0.1', '>=0.1.0 <0.2.0'],
|
||||
['^1.0', '>=1.0.0 <2.0.0'],
|
||||
['^1.2', '>=1.2.0 <2.0.0'],
|
||||
['^0.0.1', '>=0.0.1 <0.0.2'],
|
||||
['^0.0.1-beta', '>=0.0.1-beta <0.0.2'],
|
||||
['^0.1.2', '>=0.1.2 <0.2.0'],
|
||||
['^1.2.3', '>=1.2.3 <2.0.0'],
|
||||
['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'],
|
||||
['<1', '<1.0.0'],
|
||||
['< 1', '<1.0.0'],
|
||||
['>=1', '>=1.0.0'],
|
||||
['>= 1', '>=1.0.0'],
|
||||
['<1.2', '<1.2.0'],
|
||||
['< 1.2', '<1.2.0'],
|
||||
['1', '>=1.0.0 <2.0.0'],
|
||||
['>01.02.03', '>1.2.3', true],
|
||||
['>01.02.03', null],
|
||||
['~1.2.3beta', '>=1.2.3-beta <1.3.0', true],
|
||||
['~1.2.3beta', null],
|
||||
['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0']
|
||||
].forEach(function(v) {
|
||||
var pre = v[0];
|
||||
var wanted = v[1];
|
||||
var loose = v[2];
|
||||
var found = validRange(pre, loose);
|
||||
|
||||
t.equal(found, wanted, 'validRange(' + pre + ') === ' + wanted);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\ncomparators test', function(t) {
|
||||
// [range, comparators]
|
||||
// turn range into a set of individual comparators
|
||||
[['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]],
|
||||
['1.0.0', [['1.0.0']]],
|
||||
['>=*', [['']]],
|
||||
['', [['']]],
|
||||
['*', [['']]],
|
||||
['*', [['']]],
|
||||
['>=1.0.0', [['>=1.0.0']]],
|
||||
['>=1.0.0', [['>=1.0.0']]],
|
||||
['>=1.0.0', [['>=1.0.0']]],
|
||||
['>1.0.0', [['>1.0.0']]],
|
||||
['>1.0.0', [['>1.0.0']]],
|
||||
['<=2.0.0', [['<=2.0.0']]],
|
||||
['1', [['>=1.0.0', '<2.0.0']]],
|
||||
['<=2.0.0', [['<=2.0.0']]],
|
||||
['<=2.0.0', [['<=2.0.0']]],
|
||||
['<2.0.0', [['<2.0.0']]],
|
||||
['<2.0.0', [['<2.0.0']]],
|
||||
['>= 1.0.0', [['>=1.0.0']]],
|
||||
['>= 1.0.0', [['>=1.0.0']]],
|
||||
['>= 1.0.0', [['>=1.0.0']]],
|
||||
['> 1.0.0', [['>1.0.0']]],
|
||||
['> 1.0.0', [['>1.0.0']]],
|
||||
['<= 2.0.0', [['<=2.0.0']]],
|
||||
['<= 2.0.0', [['<=2.0.0']]],
|
||||
['<= 2.0.0', [['<=2.0.0']]],
|
||||
['< 2.0.0', [['<2.0.0']]],
|
||||
['<\t2.0.0', [['<2.0.0']]],
|
||||
['>=0.1.97', [['>=0.1.97']]],
|
||||
['>=0.1.97', [['>=0.1.97']]],
|
||||
['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]],
|
||||
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
|
||||
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
|
||||
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
|
||||
['||', [[''], ['']]],
|
||||
['2.x.x', [['>=2.0.0', '<3.0.0']]],
|
||||
['1.2.x', [['>=1.2.0', '<1.3.0']]],
|
||||
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
|
||||
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
|
||||
['x', [['']]],
|
||||
['2.*.*', [['>=2.0.0', '<3.0.0']]],
|
||||
['1.2.*', [['>=1.2.0', '<1.3.0']]],
|
||||
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
|
||||
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
|
||||
['*', [['']]],
|
||||
['2', [['>=2.0.0', '<3.0.0']]],
|
||||
['2.3', [['>=2.3.0', '<2.4.0']]],
|
||||
['~2.4', [['>=2.4.0', '<2.5.0']]],
|
||||
['~2.4', [['>=2.4.0', '<2.5.0']]],
|
||||
['~>3.2.1', [['>=3.2.1', '<3.3.0']]],
|
||||
['~1', [['>=1.0.0', '<2.0.0']]],
|
||||
['~>1', [['>=1.0.0', '<2.0.0']]],
|
||||
['~> 1', [['>=1.0.0', '<2.0.0']]],
|
||||
['~1.0', [['>=1.0.0', '<1.1.0']]],
|
||||
['~ 1.0', [['>=1.0.0', '<1.1.0']]],
|
||||
['~ 1.0.3', [['>=1.0.3', '<1.1.0']]],
|
||||
['~> 1.0.3', [['>=1.0.3', '<1.1.0']]],
|
||||
['<1', [['<1.0.0']]],
|
||||
['< 1', [['<1.0.0']]],
|
||||
['>=1', [['>=1.0.0']]],
|
||||
['>= 1', [['>=1.0.0']]],
|
||||
['<1.2', [['<1.2.0']]],
|
||||
['< 1.2', [['<1.2.0']]],
|
||||
['1', [['>=1.0.0', '<2.0.0']]],
|
||||
['1 2', [['>=1.0.0', '<2.0.0', '>=2.0.0', '<3.0.0']]],
|
||||
['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]],
|
||||
['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]],
|
||||
['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]],
|
||||
['>*', [['<0.0.0']]],
|
||||
['<*', [['<0.0.0']]]
|
||||
].forEach(function(v) {
|
||||
var pre = v[0];
|
||||
var wanted = v[1];
|
||||
var found = toComparators(v[0]);
|
||||
var jw = JSON.stringify(wanted);
|
||||
t.equivalent(found, wanted, 'toComparators(' + pre + ') === ' + jw);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\ninvalid version numbers', function(t) {
|
||||
['1.2.3.4',
|
||||
'NOT VALID',
|
||||
1.2,
|
||||
null,
|
||||
'Infinity.NaN.Infinity'
|
||||
].forEach(function(v) {
|
||||
t.throws(function() {
|
||||
new SemVer(v);
|
||||
}, {name:'TypeError', message:'Invalid Version: ' + v});
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nstrict vs loose version numbers', function(t) {
|
||||
[['=1.2.3', '1.2.3'],
|
||||
['01.02.03', '1.2.3'],
|
||||
['1.2.3-beta.01', '1.2.3-beta.1'],
|
||||
[' =1.2.3', '1.2.3'],
|
||||
['1.2.3foo', '1.2.3-foo']
|
||||
].forEach(function(v) {
|
||||
var loose = v[0];
|
||||
var strict = v[1];
|
||||
t.throws(function() {
|
||||
new SemVer(loose);
|
||||
});
|
||||
var lv = new SemVer(loose, true);
|
||||
t.equal(lv.version, strict);
|
||||
t.ok(eq(loose, strict, true));
|
||||
t.throws(function() {
|
||||
eq(loose, strict);
|
||||
});
|
||||
t.throws(function() {
|
||||
new SemVer(strict).compare(loose);
|
||||
});
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nstrict vs loose ranges', function(t) {
|
||||
[['>=01.02.03', '>=1.2.3'],
|
||||
['~1.02.03beta', '>=1.2.3-beta <1.3.0']
|
||||
].forEach(function(v) {
|
||||
var loose = v[0];
|
||||
var comps = v[1];
|
||||
t.throws(function() {
|
||||
new Range(loose);
|
||||
});
|
||||
t.equal(new Range(loose, true).range, comps);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nmax satisfying', function(t) {
|
||||
[[['1.2.3', '1.2.4'], '1.2', '1.2.4'],
|
||||
[['1.2.4', '1.2.3'], '1.2', '1.2.4'],
|
||||
[['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'],
|
||||
[['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true]
|
||||
].forEach(function(v) {
|
||||
var versions = v[0];
|
||||
var range = v[1];
|
||||
var expect = v[2];
|
||||
var loose = v[3];
|
||||
var actual = semver.maxSatisfying(versions, range, loose);
|
||||
t.equal(actual, expect);
|
||||
});
|
||||
t.end();
|
||||
});
|
181
node_modules/agent-base/node_modules/semver/test/ltr.js
generated
vendored
Normal file
181
node_modules/agent-base/node_modules/semver/test/ltr.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
var tap = require('tap');
|
||||
var test = tap.test;
|
||||
var semver = require('../semver.js');
|
||||
var ltr = semver.ltr;
|
||||
|
||||
test('\nltr tests', function(t) {
|
||||
// [range, version, loose]
|
||||
// Version should be less than range
|
||||
[
|
||||
['~1.2.2', '1.2.1'],
|
||||
['~0.6.1-1', '0.6.1-0'],
|
||||
['1.0.0 - 2.0.0', '0.0.1'],
|
||||
['1.0.0-beta.2', '1.0.0-beta.1'],
|
||||
['1.0.0', '0.0.0'],
|
||||
['>=2.0.0', '1.1.1'],
|
||||
['>=2.0.0', '1.2.9'],
|
||||
['>2.0.0', '2.0.0'],
|
||||
['0.1.20 || 1.2.4', '0.1.5'],
|
||||
['2.x.x', '1.0.0'],
|
||||
['1.2.x', '1.1.0'],
|
||||
['1.2.x || 2.x', '1.0.0'],
|
||||
['2.*.*', '1.0.1'],
|
||||
['1.2.*', '1.1.3'],
|
||||
['1.2.* || 2.*', '1.1.9999'],
|
||||
['2', '1.0.0'],
|
||||
['2.3', '2.2.2'],
|
||||
['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.3.5'],
|
||||
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
|
||||
['~1', '0.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '0.2.4'],
|
||||
['~> 1', '0.2.3'],
|
||||
['~1.0', '0.1.2'], // >=1.0.0 <1.1.0
|
||||
['~ 1.0', '0.1.0'],
|
||||
['>1.2', '1.2.0'],
|
||||
['> 1.2', '1.2.1'],
|
||||
['1', '0.0.0beta', true],
|
||||
['~v0.5.4-pre', '0.5.4-alpha'],
|
||||
['~v0.5.4-pre', '0.5.4-alpha'],
|
||||
['=0.7.x', '0.6.0'],
|
||||
['=0.7.x', '0.6.0-asdf'],
|
||||
['>=0.7.x', '0.6.0'],
|
||||
['~1.2.2', '1.2.1'],
|
||||
['1.0.0 - 2.0.0', '0.2.3'],
|
||||
['1.0.0', '0.0.1'],
|
||||
['>=2.0.0', '1.0.0'],
|
||||
['>=2.0.0', '1.9999.9999'],
|
||||
['>=2.0.0', '1.2.9'],
|
||||
['>2.0.0', '2.0.0'],
|
||||
['>2.0.0', '1.2.9'],
|
||||
['2.x.x', '1.1.3'],
|
||||
['1.2.x', '1.1.3'],
|
||||
['1.2.x || 2.x', '1.1.3'],
|
||||
['2.*.*', '1.1.3'],
|
||||
['1.2.*', '1.1.3'],
|
||||
['1.2.* || 2.*', '1.1.3'],
|
||||
['2', '1.9999.9999'],
|
||||
['2.3', '2.2.1'],
|
||||
['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
|
||||
['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0
|
||||
['~1', '0.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '0.2.3'],
|
||||
['~1.0', '0.0.0'], // >=1.0.0 <1.1.0
|
||||
['>1', '1.0.0'],
|
||||
['2', '1.0.0beta', true],
|
||||
['>1', '1.0.0beta', true],
|
||||
['> 1', '1.0.0beta', true],
|
||||
['=0.7.x', '0.6.2'],
|
||||
['=0.7.x', '0.7.0-asdf'],
|
||||
['^1', '1.0.0-0'],
|
||||
['>=0.7.x', '0.7.0-asdf'],
|
||||
['1', '1.0.0beta', true],
|
||||
['>=0.7.x', '0.6.2'],
|
||||
['>1.2.3', '1.3.0-alpha']
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = 'ltr(' + version + ', ' + range + ', ' + loose + ')';
|
||||
t.ok(ltr(version, range, loose), msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nnegative ltr tests', function(t) {
|
||||
// [range, version, loose]
|
||||
// Version should NOT be less than range
|
||||
[
|
||||
['~ 1.0', '1.1.0'],
|
||||
['~0.6.1-1', '0.6.1-1'],
|
||||
['1.0.0 - 2.0.0', '1.2.3'],
|
||||
['1.0.0 - 2.0.0', '2.9.9'],
|
||||
['1.0.0', '1.0.0'],
|
||||
['>=*', '0.2.4'],
|
||||
['', '1.0.0', true],
|
||||
['*', '1.2.3'],
|
||||
['>=1.0.0', '1.0.0'],
|
||||
['>=1.0.0', '1.0.1'],
|
||||
['>=1.0.0', '1.1.0'],
|
||||
['>1.0.0', '1.0.1'],
|
||||
['>1.0.0', '1.1.0'],
|
||||
['<=2.0.0', '2.0.0'],
|
||||
['<=2.0.0', '1.9999.9999'],
|
||||
['<=2.0.0', '0.2.9'],
|
||||
['<2.0.0', '1.9999.9999'],
|
||||
['<2.0.0', '0.2.9'],
|
||||
['>= 1.0.0', '1.0.0'],
|
||||
['>= 1.0.0', '1.0.1'],
|
||||
['>= 1.0.0', '1.1.0'],
|
||||
['> 1.0.0', '1.0.1'],
|
||||
['> 1.0.0', '1.1.0'],
|
||||
['<= 2.0.0', '2.0.0'],
|
||||
['<= 2.0.0', '1.9999.9999'],
|
||||
['<= 2.0.0', '0.2.9'],
|
||||
['< 2.0.0', '1.9999.9999'],
|
||||
['<\t2.0.0', '0.2.9'],
|
||||
['>=0.1.97', 'v0.1.97'],
|
||||
['>=0.1.97', '0.1.97'],
|
||||
['0.1.20 || 1.2.4', '1.2.4'],
|
||||
['0.1.20 || >1.2.4', '1.2.4'],
|
||||
['0.1.20 || 1.2.4', '1.2.3'],
|
||||
['0.1.20 || 1.2.4', '0.1.20'],
|
||||
['>=0.2.3 || <0.0.1', '0.0.0'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.3'],
|
||||
['>=0.2.3 || <0.0.1', '0.2.4'],
|
||||
['||', '1.3.4'],
|
||||
['2.x.x', '2.1.3'],
|
||||
['1.2.x', '1.2.3'],
|
||||
['1.2.x || 2.x', '2.1.3'],
|
||||
['1.2.x || 2.x', '1.2.3'],
|
||||
['x', '1.2.3'],
|
||||
['2.*.*', '2.1.3'],
|
||||
['1.2.*', '1.2.3'],
|
||||
['1.2.* || 2.*', '2.1.3'],
|
||||
['1.2.* || 2.*', '1.2.3'],
|
||||
['1.2.* || 2.*', '1.2.3'],
|
||||
['*', '1.2.3'],
|
||||
['2', '2.1.2'],
|
||||
['2.3', '2.3.1'],
|
||||
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
|
||||
['~2.4', '2.4.5'],
|
||||
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
|
||||
['~1', '1.2.3'], // >=1.0.0 <2.0.0
|
||||
['~>1', '1.2.3'],
|
||||
['~> 1', '1.2.3'],
|
||||
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
|
||||
['~ 1.0', '1.0.2'],
|
||||
['>=1', '1.0.0'],
|
||||
['>= 1', '1.0.0'],
|
||||
['<1.2', '1.1.1'],
|
||||
['< 1.2', '1.1.1'],
|
||||
['~v0.5.4-pre', '0.5.5'],
|
||||
['~v0.5.4-pre', '0.5.4'],
|
||||
['=0.7.x', '0.7.2'],
|
||||
['>=0.7.x', '0.7.2'],
|
||||
['<=0.7.x', '0.6.2'],
|
||||
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
|
||||
['>=0.2.3 <=0.2.4', '0.2.4'],
|
||||
['1.0.0 - 2.0.0', '2.0.0'],
|
||||
['^3.0.0', '4.0.0'],
|
||||
['^1.0.0 || ~2.0.1', '2.0.0'],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
|
||||
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
|
||||
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'],
|
||||
['^1.0.0alpha', '1.0.0beta', true],
|
||||
['~1.0.0alpha', '1.0.0beta', true],
|
||||
['^1.0.0-alpha', '1.0.0beta', true],
|
||||
['~1.0.0-alpha', '1.0.0beta', true],
|
||||
['^1.0.0-alpha', '1.0.0-beta'],
|
||||
['~1.0.0-alpha', '1.0.0-beta'],
|
||||
['=0.1.0', '1.0.0']
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = '!ltr(' + version + ', ' + range + ', ' + loose + ')';
|
||||
t.notOk(ltr(version, range, loose), msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
72
node_modules/agent-base/node_modules/semver/test/major-minor-patch.js
generated
vendored
Normal file
72
node_modules/agent-base/node_modules/semver/test/major-minor-patch.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
var tap = require('tap');
|
||||
var test = tap.test;
|
||||
var semver = require('../semver.js');
|
||||
|
||||
test('\nmajor tests', function(t) {
|
||||
// [range, version]
|
||||
// Version should be detectable despite extra characters
|
||||
[
|
||||
['1.2.3', 1],
|
||||
[' 1.2.3 ', 1],
|
||||
[' 2.2.3-4 ', 2],
|
||||
[' 3.2.3-pre ', 3],
|
||||
['v5.2.3', 5],
|
||||
[' v8.2.3 ', 8],
|
||||
['\t13.2.3', 13],
|
||||
['=21.2.3', 21, true],
|
||||
['v=34.2.3', 34, true]
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = 'major(' + range + ') = ' + version;
|
||||
t.equal(semver.major(range, loose), version, msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\nminor tests', function(t) {
|
||||
// [range, version]
|
||||
// Version should be detectable despite extra characters
|
||||
[
|
||||
['1.1.3', 1],
|
||||
[' 1.1.3 ', 1],
|
||||
[' 1.2.3-4 ', 2],
|
||||
[' 1.3.3-pre ', 3],
|
||||
['v1.5.3', 5],
|
||||
[' v1.8.3 ', 8],
|
||||
['\t1.13.3', 13],
|
||||
['=1.21.3', 21, true],
|
||||
['v=1.34.3', 34, true]
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = 'minor(' + range + ') = ' + version;
|
||||
t.equal(semver.minor(range, loose), version, msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('\npatch tests', function(t) {
|
||||
// [range, version]
|
||||
// Version should be detectable despite extra characters
|
||||
[
|
||||
['1.2.1', 1],
|
||||
[' 1.2.1 ', 1],
|
||||
[' 1.2.2-4 ', 2],
|
||||
[' 1.2.3-pre ', 3],
|
||||
['v1.2.5', 5],
|
||||
[' v1.2.8 ', 8],
|
||||
['\t1.2.13', 13],
|
||||
['=1.2.21', 21, true],
|
||||
['v=1.2.34', 34, true]
|
||||
].forEach(function(tuple) {
|
||||
var range = tuple[0];
|
||||
var version = tuple[1];
|
||||
var loose = tuple[2] || false;
|
||||
var msg = 'patch(' + range + ') = ' + version;
|
||||
t.equal(semver.patch(range, loose), version, msg);
|
||||
});
|
||||
t.end();
|
||||
});
|
85
node_modules/agent-base/package.json
generated
vendored
Normal file
85
node_modules/agent-base/package.json
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"agent-base@2",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\http-proxy-agent"
|
||||
]
|
||||
],
|
||||
"_from": "agent-base@>=2.0.0-0 <3.0.0-0",
|
||||
"_id": "agent-base@2.0.1",
|
||||
"_inCache": true,
|
||||
"_location": "/agent-base",
|
||||
"_nodeVersion": "0.12.7",
|
||||
"_npmUser": {
|
||||
"email": "nathan@tootallnate.net",
|
||||
"name": "tootallnate"
|
||||
},
|
||||
"_npmVersion": "2.11.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "agent-base",
|
||||
"raw": "agent-base@2",
|
||||
"rawSpec": "2",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.0-0 <3.0.0-0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/http-proxy-agent",
|
||||
"/https-proxy-agent"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz",
|
||||
"_shasum": "bd8f9e86a8eb221fffa07bd14befd55df142815e",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "agent-base@2",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton\\node_modules\\http-proxy-agent",
|
||||
"author": {
|
||||
"email": "nathan@tootallnate.net",
|
||||
"name": "Nathan Rajlich",
|
||||
"url": "http://n8.io/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-agent-base/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"extend": "~3.0.0",
|
||||
"semver": "~5.0.1"
|
||||
},
|
||||
"description": "Turn a function into an `http.Agent` instance",
|
||||
"devDependencies": {
|
||||
"mocha": "2"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "bd8f9e86a8eb221fffa07bd14befd55df142815e",
|
||||
"tarball": "https://registry.npmjs.org/agent-base/-/agent-base-2.0.1.tgz"
|
||||
},
|
||||
"gitHead": "b46938339bcecd261939dc55798270d0398ad8f0",
|
||||
"homepage": "https://github.com/TooTallNate/node-agent-base#readme",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"agent",
|
||||
"barebones",
|
||||
"base",
|
||||
"http",
|
||||
"https"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "agent.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
}
|
||||
],
|
||||
"name": "agent-base",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-agent-base.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec"
|
||||
},
|
||||
"version": "2.0.1"
|
||||
}
|
54
node_modules/agent-base/patch-core.js
generated
vendored
Normal file
54
node_modules/agent-base/patch-core.js
generated
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var semver = require('semver');
|
||||
var inherits = require('util').inherits;
|
||||
|
||||
|
||||
// we only need to patch the `http.request()` and
|
||||
// `http.ClientRequest` on older versions of Node.js
|
||||
if (semver.lt(process.version, '0.11.8')) {
|
||||
// subclass the native ClientRequest to include the
|
||||
// passed in `options` object.
|
||||
http.ClientRequest = (function (_ClientRequest) {
|
||||
function ClientRequest (options, cb) {
|
||||
this._options = options;
|
||||
_ClientRequest.call(this, options, cb);
|
||||
}
|
||||
inherits(ClientRequest, _ClientRequest);
|
||||
|
||||
return ClientRequest;
|
||||
})(http.ClientRequest);
|
||||
|
||||
|
||||
// need to re-define the `request()` method, since on node v0.8/v0.10
|
||||
// the closure-local ClientRequest is used, rather than the monkey
|
||||
// patched version we have created here.
|
||||
http.request = (function (request) {
|
||||
return function (options, cb) {
|
||||
if (typeof options === 'string') {
|
||||
options = url.parse(options);
|
||||
}
|
||||
if (options.protocol && options.protocol !== 'http:') {
|
||||
throw new Error('Protocol:' + options.protocol + ' not supported.');
|
||||
}
|
||||
return new http.ClientRequest(options, cb);
|
||||
};
|
||||
})(http.request);
|
||||
}
|
||||
|
||||
|
||||
// this currently needs to be applied to all Node.js versions
|
||||
// (v0.8.x, v0.10.x, v0.12.x), in order to determine if the `req`
|
||||
// is an HTTP or HTTPS request. There is currently no PR attempting
|
||||
// to move this property upstream.
|
||||
https.request = (function (request) {
|
||||
return function (options, cb) {
|
||||
if (typeof options === 'string') {
|
||||
options = url.parse(options);
|
||||
}
|
||||
if (null == options.port) options.port = 443;
|
||||
options.secureEndpoint = true;
|
||||
return request.call(https, options, cb);
|
||||
};
|
||||
})(https.request);
|
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
Normal file
15
node_modules/agent-base/test/ssl-cert-snakeoil.key
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICWwIBAAKBgQCzURxIqzer0ACAbX/lHdsn4Gd9PLKrf7EeDYfIdV0HZKPD8WDr
|
||||
bBx2/fBu0OW2sjnzv/SVZbJ0DAuPE/p0+eT0qb2qC10iz9iTD7ribd7gxhirVb8y
|
||||
b3fBjXsxc8V8p4Ny1LcvNSqCjwUbJqdRogfoJeTiqPM58z5sNzuv5iq7iwIDAQAB
|
||||
AoGAPMQy4olrP0UotlzlJ36bowLP70ffgHCwU+/f4NWs5fF78c3du0oSx1w820Dd
|
||||
Z7E0JF8bgnlJJTxjumPZz0RUCugrEHBKJmzEz3cxF5E3+7NvteZcjKn9D67RrM5x
|
||||
1/uSZ9cqKE9cYvY4fSuHx18diyZ4axR/wB1Pea2utjjDM+ECQQDb9ZbmmaWMiRpQ
|
||||
5Up+loxP7BZNPsEVsm+DVJmEFbaFgGfncWBqSIqnPNjMwTwj0OigTwCAEGPkfRVW
|
||||
T0pbYWCxAkEA0LK7SCTwzyDmhASUalk0x+3uCAA6ryFdwJf/wd8TRAvVOmkTEldX
|
||||
uJ7ldLvfrONYO3v56uKTU/SoNdZYzKtO+wJAX2KM4ctXYy5BXztPpr2acz4qHa1N
|
||||
Bh+vBAC34fOYhyQ76r3b1btHhWZ5jbFuZwm9F2erC94Ps5IaoqcX07DSwQJAPKGw
|
||||
h2U0EPkd/3zVIZCJJQya+vgWFIs9EZcXVtvYXQyTBkVApTN66MhBIYjzkub5205J
|
||||
bVQmOV37AKklY1DhwQJAA1wos0cYxro02edzatxd0DIR2r4qqOqLkw6BhYHhq6HJ
|
||||
ZvIcQkHqdSXzdETFc01I1znDGGIrJHcnvKWgBPoEUg==
|
||||
-----END RSA PRIVATE KEY-----
|
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
Normal file
12
node_modules/agent-base/test/ssl-cert-snakeoil.pem
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIB1TCCAT4CCQDV5mPlzm9+izANBgkqhkiG9w0BAQUFADAvMS0wKwYDVQQDEyQ3
|
||||
NTI3YmQ3Ny1hYjNlLTQ3NGItYWNlNy1lZWQ2MDUzOTMxZTcwHhcNMTUwNzA2MjI0
|
||||
NTA3WhcNMjUwNzAzMjI0NTA3WjAvMS0wKwYDVQQDEyQ3NTI3YmQ3Ny1hYjNlLTQ3
|
||||
NGItYWNlNy1lZWQ2MDUzOTMxZTcwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
|
||||
ALNRHEirN6vQAIBtf+Ud2yfgZ308sqt/sR4Nh8h1XQdko8PxYOtsHHb98G7Q5bay
|
||||
OfO/9JVlsnQMC48T+nT55PSpvaoLXSLP2JMPuuJt3uDGGKtVvzJvd8GNezFzxXyn
|
||||
g3LUty81KoKPBRsmp1GiB+gl5OKo8znzPmw3O6/mKruLAgMBAAEwDQYJKoZIhvcN
|
||||
AQEFBQADgYEACzoHUF8UV2Z6541Q2wKEA0UFUzmUjf/E1XwBO+1P15ZZ64uw34B4
|
||||
1RwMPtAo9RY/PmICTWtNxWGxkzwb2JtDWtnxVER/lF8k2XcXPE76fxTHJF/BKk9J
|
||||
QU8OTD1dd9gHCBviQB9TqntRZ5X7axjtuWjb2umY+owBYzAHZkp1HKI=
|
||||
-----END CERTIFICATE-----
|
300
node_modules/agent-base/test/test.js
generated
vendored
Normal file
300
node_modules/agent-base/test/test.js
generated
vendored
Normal file
@ -0,0 +1,300 @@
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var fs = require('fs');
|
||||
var url = require('url');
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var assert = require('assert');
|
||||
var events = require('events');
|
||||
var Agent = require('../');
|
||||
|
||||
describe('Agent', function () {
|
||||
describe('"error" event', function () {
|
||||
it('should be invoked on `http.ClientRequest` instance if passed to callback function on the first tick', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
fn(new Error('is this caught?'));
|
||||
});
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function (err) {
|
||||
assert.equal('is this caught?', err.message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should be invoked on `http.ClientRequest` instance if passed to callback function after the first tick', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
setTimeout(function () {
|
||||
fn(new Error('is this caught?'));
|
||||
}, 10);
|
||||
});
|
||||
var info = url.parse('http://127.0.0.1/foo');
|
||||
info.agent = agent;
|
||||
var req = http.get(info);
|
||||
req.on('error', function (err) {
|
||||
assert.equal('is this caught?', err.message);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('artificial "streams"', function () {
|
||||
it('should send a GET request', function (done) {
|
||||
var stream = new events.EventEmitter();
|
||||
|
||||
// needed for the `http` module to call .write() on the stream
|
||||
stream.writable = true;
|
||||
|
||||
stream.write = function (str) {
|
||||
assert(0 == str.indexOf('GET / HTTP/1.1'));
|
||||
done();
|
||||
};
|
||||
|
||||
var opts = {
|
||||
method: 'GET',
|
||||
host: '127.0.0.1',
|
||||
path: '/',
|
||||
port: 80,
|
||||
agent: new Agent(function (req, opts, fn) {
|
||||
fn(null, stream);
|
||||
})
|
||||
};
|
||||
var req = http.request(opts);
|
||||
req.end();
|
||||
});
|
||||
it('should receive a GET response', function (done) {
|
||||
var stream = new events.EventEmitter();
|
||||
var opts = {
|
||||
method: 'GET',
|
||||
host: '127.0.0.1',
|
||||
path: '/',
|
||||
port: 80,
|
||||
agent: new Agent(function (req, opts, fn) {
|
||||
fn(null, stream);
|
||||
})
|
||||
};
|
||||
var req = http.request(opts, function (res) {
|
||||
assert.equal('0.9', res.httpVersion);
|
||||
assert.equal(111, res.statusCode);
|
||||
assert.equal('bar', res.headers.foo);
|
||||
done();
|
||||
});
|
||||
req.end();
|
||||
|
||||
// have to nextTick() since `http.ClientRequest` doesn't *actually*
|
||||
// attach the listeners to the "stream" until the next tick :\
|
||||
process.nextTick(function () {
|
||||
var buf = new Buffer('HTTP/0.9 111\r\n' +
|
||||
'Foo: bar\r\n' +
|
||||
'Set-Cookie: 1\r\n' +
|
||||
'Set-Cookie: 2\r\n\r\n');
|
||||
if ('function' == typeof stream.ondata) {
|
||||
// node <= v0.11.3
|
||||
stream.ondata(buf, 0, buf.length);
|
||||
} else {
|
||||
// node > v0.11.3
|
||||
stream.emit('data', buf);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"http" module', function () {
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTP server
|
||||
before(function (done) {
|
||||
server = http.createServer();
|
||||
server.listen(0, function () {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function (done) {
|
||||
server.once('close', function () {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should work for basic HTTP requests', function (done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
called = true;
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function (req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
http.get(info, function (res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should set the `Connection: close` response header', function (done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
called = true;
|
||||
var socket = net.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTP server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function (req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Url', req.url);
|
||||
assert.equal('close', req.headers.connection);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('http://127.0.0.1:' + port + '/bar');
|
||||
info.agent = agent;
|
||||
http.get(info, function (res) {
|
||||
assert.equal('/bar', res.headers['x-url']);
|
||||
assert.equal('close', res.headers.connection);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass through options from `http.request()`', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
assert.equal('google.com', opts.host);
|
||||
assert.equal('bar', opts.foo);
|
||||
done();
|
||||
});
|
||||
|
||||
http.get({
|
||||
host: 'google.com',
|
||||
foo: 'bar',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
|
||||
it('should default to port 80', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
assert.equal(80, opts.port);
|
||||
done();
|
||||
});
|
||||
|
||||
// (probably) not hitting a real HTTP server here,
|
||||
// so no need to add a httpServer request listener
|
||||
http.get({
|
||||
host: '127.0.0.1',
|
||||
path: '/foo',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('"https" module', function () {
|
||||
var server;
|
||||
var port;
|
||||
|
||||
// setup test HTTPS server
|
||||
before(function (done) {
|
||||
var options = {
|
||||
key: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.key'),
|
||||
cert: fs.readFileSync(__dirname + '/ssl-cert-snakeoil.pem')
|
||||
};
|
||||
server = https.createServer(options);
|
||||
server.listen(0, function () {
|
||||
port = server.address().port;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
// shut down test HTTP server
|
||||
after(function (done) {
|
||||
server.once('close', function () {
|
||||
done();
|
||||
});
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('should work for basic HTTPS requests', function (done) {
|
||||
var called = false;
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
called = true;
|
||||
assert(opts.secureEndpoint);
|
||||
var socket = tls.connect(opts);
|
||||
fn(null, socket);
|
||||
});
|
||||
|
||||
// add HTTPS server "request" listener
|
||||
var gotReq = false;
|
||||
server.once('request', function (req, res) {
|
||||
gotReq = true;
|
||||
res.setHeader('X-Foo', 'bar');
|
||||
res.setHeader('X-Url', req.url);
|
||||
res.end();
|
||||
});
|
||||
|
||||
var info = url.parse('https://127.0.0.1:' + port + '/foo');
|
||||
info.agent = agent;
|
||||
info.rejectUnauthorized = false;
|
||||
https.get(info, function (res) {
|
||||
assert.equal('bar', res.headers['x-foo']);
|
||||
assert.equal('/foo', res.headers['x-url']);
|
||||
assert(gotReq);
|
||||
assert(called);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass through options from `https.request()`', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
assert.equal('google.com', opts.host);
|
||||
assert.equal('bar', opts.foo);
|
||||
done();
|
||||
});
|
||||
|
||||
https.get({
|
||||
host: 'google.com',
|
||||
foo: 'bar',
|
||||
agent: agent
|
||||
});
|
||||
});
|
||||
|
||||
it('should default to port 443', function (done) {
|
||||
var agent = new Agent(function (req, opts, fn) {
|
||||
assert.equal(true, opts.secureEndpoint);
|
||||
assert.equal(false, opts.rejectUnauthorized);
|
||||
assert.equal(443, opts.port);
|
||||
done();
|
||||
});
|
||||
|
||||
// (probably) not hitting a real HTTPS server here,
|
||||
// so no need to add a httpsServer request listener
|
||||
https.get({
|
||||
host: '127.0.0.1',
|
||||
path: '/foo',
|
||||
agent: agent,
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user