mirror of https://github.com/lukechilds/node.git
Browse Source
No more cherry-picked io patches. hooray. PR-URL: https://github.com/nodejs/node/pull/2822 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>v4.x
Kat Marchán
9 years ago
committed by
Jeremiah Senkpiel
56 changed files with 1050 additions and 5060 deletions
@ -0,0 +1 @@ |
|||
../node-gyp/bin/node-gyp.js |
@ -1 +1,3 @@ |
|||
gyp/test |
|||
node_modules |
|||
test/.node-gyp |
|||
|
@ -0,0 +1,24 @@ |
|||
v3.0.3 2015-09-14 |
|||
|
|||
* [[`ad827cda30`](https://github.com/nodejs/node-gyp/commit/ad827cda30)] - tarballUrl global and && when checking for iojs (Lars-Magnus Skog) [#729](https://github.com/nodejs/node-gyp/pull/729) |
|||
|
|||
v3.0.2 2015-09-12 |
|||
|
|||
* [[`6e8c3bf3c6`](https://github.com/nodejs/node-gyp/commit/6e8c3bf3c6)] - add back support for passing additional cmdline args (Rod Vagg) [#723](https://github.com/nodejs/node-gyp/pull/723) |
|||
* [[`ff82f2f3b9`](https://github.com/nodejs/node-gyp/commit/ff82f2f3b9)] - fixed broken link in docs to Visual Studio 2013 download (simon-p-r) [#722](https://github.com/nodejs/node-gyp/pull/722) |
|||
|
|||
v3.0.1 2015-09-08 |
|||
|
|||
* [[`846337e36b`](https://github.com/nodejs/node-gyp/commit/846337e36b)] - normalise versions for target == this comparison (Rod Vagg) [#716](https://github.com/nodejs/node-gyp/pull/716) |
|||
|
|||
v3.0.0 2015-09-08 |
|||
|
|||
* [[`9720d0373c`](https://github.com/nodejs/node-gyp/commit/9720d0373c)] - remove node_modules from tree (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) |
|||
* [[`6dcf220db7`](https://github.com/nodejs/node-gyp/commit/6dcf220db7)] - test version major directly, don't use semver.satisfies() (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) |
|||
* [[`938dd18d1c`](https://github.com/nodejs/node-gyp/commit/938dd18d1c)] - refactor for clarity, fix dist-url, add env var dist-url functionality (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) |
|||
* [[`9e9df66a06`](https://github.com/nodejs/node-gyp/commit/9e9df66a06)] - use process.release, make aware of io.js & node v4 differences (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) |
|||
* [[`1ea7ed01f4`](https://github.com/nodejs/node-gyp/commit/1ea7ed01f4)] - **deps**: update graceful-fs dependency to the latest (Sakthipriyan Vairamani) [#714](https://github.com/nodejs/node-gyp/pull/714) |
|||
* [[`0fbc387b35`](https://github.com/nodejs/node-gyp/commit/0fbc387b35)] - Update repository URLs. (Ben Noordhuis) [#715](https://github.com/nodejs/node-gyp/pull/715) |
|||
* [[`bbedb8868b`](https://github.com/nodejs/node-gyp/commit/bbedb8868b)] - **(SEMVER-MAJOR)** **win**: enable delay-load hook by default (Jeremiah Senkpiel) [#708](https://github.com/nodejs/node-gyp/pull/708) |
|||
* [[`85ed107565`](https://github.com/nodejs/node-gyp/commit/85ed107565)] - Merge pull request #664 from othiym23/othiym23/allow-semver-5 (Nathan Rajlich) |
|||
* [[`0c720d234c`](https://github.com/nodejs/node-gyp/commit/0c720d234c)] - allow semver@5 (Forrest L Norvell) |
@ -0,0 +1,133 @@ |
|||
var semver = require('semver') |
|||
, url = require('url') |
|||
, path = require('path') |
|||
|
|||
, bitsre = /\/win-(x86|x64)\// |
|||
, bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should
|
|||
// have been "x86"
|
|||
|
|||
// Captures all the logic required to determine download URLs, local directory and
|
|||
// file names. Inputs come from command-line switches (--target, --dist-url),
|
|||
// `process.version` and `process.release` where it exists.
|
|||
function processRelease (argv, gyp, defaultVersion, defaultRelease) { |
|||
var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion |
|||
, versionSemver = semver.parse(version) |
|||
, overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl |
|||
, isDefaultVersion |
|||
, isIojs |
|||
, name |
|||
, distBaseUrl |
|||
, baseUrl |
|||
, libUrl32 |
|||
, libUrl64 |
|||
, tarballUrl |
|||
|
|||
if (!versionSemver) { |
|||
// not a valid semver string, nothing we can do
|
|||
return { version: version } |
|||
} |
|||
// flatten version into String
|
|||
version = versionSemver.version |
|||
|
|||
// defaultVersion should come from process.version so ought to be valid semver
|
|||
isDefaultVersion = version === semver.parse(defaultVersion).version |
|||
|
|||
// can't use process.release if we're using --target=x.y.z
|
|||
if (!isDefaultVersion) |
|||
defaultRelease = null |
|||
|
|||
if (defaultRelease) { |
|||
// v3 onward, has process.release
|
|||
name = defaultRelease.name.replace(/io\.js/, 'iojs') // remove the '.' for directory naming purposes
|
|||
isIojs = name === 'iojs' |
|||
} else { |
|||
// old node or alternative --target=
|
|||
// semver.satisfies() doesn't like prerelease tags so test major directly
|
|||
isIojs = versionSemver.major >= 1 && versionSemver.major < 4 |
|||
name = isIojs ? 'iojs' : 'node' |
|||
} |
|||
|
|||
// check for the nvm.sh standard mirror env variables
|
|||
if (!overrideDistUrl) { |
|||
if (isIojs && process.env.NVM_IOJS_ORG_MIRROR) |
|||
overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR |
|||
else if (process.env.NVM_NODEJS_ORG_MIRROR) |
|||
overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR |
|||
} |
|||
|
|||
|
|||
if (overrideDistUrl) |
|||
distBaseUrl = overrideDistUrl.replace(/\/+$/, '') |
|||
else |
|||
distBaseUrl = isIojs ? 'https://iojs.org/download/release' : 'https://nodejs.org/dist' |
|||
distBaseUrl += '/v' + version + '/' |
|||
|
|||
// new style, based on process.release so we have a lot of the data we need
|
|||
if (defaultRelease && defaultRelease.headersUrl && !overrideDistUrl) { |
|||
baseUrl = url.resolve(defaultRelease.headersUrl, './') |
|||
libUrl32 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x86', versionSemver.major) |
|||
libUrl64 = resolveLibUrl(name, defaultRelease.libUrl || baseUrl || distBaseUrl, 'x64', versionSemver.major) |
|||
|
|||
return { |
|||
version: version, |
|||
semver: versionSemver, |
|||
name: name, |
|||
baseUrl: baseUrl, |
|||
tarballUrl: defaultRelease.headersUrl, |
|||
shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'), |
|||
versionDir: (name !== 'node' ? name + '-' : '') + version, |
|||
libUrl32: libUrl32, |
|||
libUrl64: libUrl64, |
|||
libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)), |
|||
libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) |
|||
} |
|||
} |
|||
|
|||
// older versions without process.release are captured here and we have to make
|
|||
// a lot of assumptions, additionally if you --target=x.y.z then we can't use the
|
|||
// current process.release
|
|||
|
|||
baseUrl = distBaseUrl |
|||
libUrl32 = resolveLibUrl(name, baseUrl, 'x86', versionSemver.major) |
|||
libUrl64 = resolveLibUrl(name, baseUrl, 'x64', versionSemver.major) |
|||
// making the bold assumption that anything with a version number >3.0.0 will
|
|||
// have a *-headers.tar.gz file in its dist location, even some frankenstein
|
|||
// custom version
|
|||
tarballUrl = url.resolve(baseUrl, name + '-v' + version + (versionSemver.major >= 3 ? '-headers' : '') + '.tar.gz') |
|||
|
|||
return { |
|||
version: version, |
|||
semver: versionSemver, |
|||
name: name, |
|||
baseUrl: baseUrl, |
|||
tarballUrl: tarballUrl, |
|||
shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'), |
|||
versionDir: (name !== 'node' ? name + '-' : '') + version, |
|||
libUrl32: libUrl32, |
|||
libUrl64: libUrl64, |
|||
libPath32: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)), |
|||
libPath64: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) |
|||
} |
|||
} |
|||
|
|||
function normalizePath (p) { |
|||
return path.normalize(p).replace(/\\/g, '/') |
|||
} |
|||
|
|||
function resolveLibUrl (name, defaultUrl, arch, versionMajor) { |
|||
var base = url.resolve(defaultUrl, './') |
|||
, hasLibUrl = bitsre.test(defaultUrl) || (versionMajor === 3 && bitsreV3.test(defaultUrl)) |
|||
|
|||
if (!hasLibUrl) { |
|||
// let's assume it's a baseUrl then
|
|||
if (versionMajor >= 1) |
|||
return url.resolve(base, 'win-' + arch +'/' + name + '.lib') |
|||
// prior to io.js@1.0.0 32-bit node.lib lives in /, 64-bit lives in /x64/
|
|||
return url.resolve(base, (arch === 'x64' ? 'x64/' : '') + name + '.lib') |
|||
} |
|||
|
|||
// else we have a proper url to a .lib, just make sure it's the right arch
|
|||
return defaultUrl.replace(versionMajor === 3 ? bitsreV3 : bitsre, '/win-' + arch + '/') |
|||
} |
|||
|
|||
module.exports = processRelease |
@ -1 +0,0 @@ |
|||
node_modules/ |
@ -1,15 +0,0 @@ |
|||
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. |
@ -1,36 +0,0 @@ |
|||
# graceful-fs |
|||
|
|||
graceful-fs functions as a drop-in replacement for the fs module, |
|||
making various improvements. |
|||
|
|||
The improvements are meant to normalize behavior across different |
|||
platforms and environments, and to make filesystem access more |
|||
resilient to errors. |
|||
|
|||
## Improvements over [fs module](http://api.nodejs.org/fs.html) |
|||
|
|||
graceful-fs: |
|||
|
|||
* Queues up `open` and `readdir` calls, and retries them once |
|||
something closes if there is an EMFILE error from too many file |
|||
descriptors. |
|||
* fixes `lchmod` for Node versions prior to 0.6.2. |
|||
* implements `fs.lutimes` if possible. Otherwise it becomes a noop. |
|||
* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or |
|||
`lchown` if the user isn't root. |
|||
* makes `lchmod` and `lchown` become noops, if not available. |
|||
* retries reading a file if `read` results in EAGAIN error. |
|||
|
|||
On Windows, it retries renaming a file for up to one second if `EACCESS` |
|||
or `EPERM` error occurs, likely because antivirus software has locked |
|||
the directory. |
|||
|
|||
## USAGE |
|||
|
|||
```javascript |
|||
// use just like fs |
|||
var fs = require('graceful-fs') |
|||
|
|||
// now go and do stuff with it... |
|||
fs.readFileSync('some-file-or-whatever') |
|||
``` |
@ -1,11 +0,0 @@ |
|||
// eeeeeevvvvviiiiiiillllll
|
|||
// more evil than monkey-patching the native builtin?
|
|||
// Not sure.
|
|||
|
|||
var mod = require("module") |
|||
var pre = '(function (exports, require, module, __filename, __dirname) { ' |
|||
var post = '});' |
|||
var src = pre + process.binding('natives').fs + post |
|||
var vm = require('vm') |
|||
var fn = vm.runInThisContext(src) |
|||
fn(exports, require, module, __filename, __dirname) |
@ -1,158 +0,0 @@ |
|||
// Monkey-patching the fs module.
|
|||
// It's ugly, but there is simply no other way to do this.
|
|||
var fs = module.exports = require('./fs.js') |
|||
|
|||
var assert = require('assert') |
|||
|
|||
// fix up some busted stuff, mostly on windows and old nodes
|
|||
require('./polyfills.js') |
|||
|
|||
var util = require('util') |
|||
|
|||
function noop () {} |
|||
|
|||
var debug = noop |
|||
if (util.debuglog) |
|||
debug = util.debuglog('gfs') |
|||
else if (/\bgfs\b/i.test(process.env.NODE_DEBUG || '')) |
|||
debug = function() { |
|||
var m = util.format.apply(util, arguments) |
|||
m = 'GFS: ' + m.split(/\n/).join('\nGFS: ') |
|||
console.error(m) |
|||
} |
|||
|
|||
if (/\bgfs\b/i.test(process.env.NODE_DEBUG || '')) { |
|||
process.on('exit', function() { |
|||
debug('fds', fds) |
|||
debug(queue) |
|||
assert.equal(queue.length, 0) |
|||
}) |
|||
} |
|||
|
|||
|
|||
var originalOpen = fs.open |
|||
fs.open = open |
|||
|
|||
function open(path, flags, mode, cb) { |
|||
if (typeof mode === "function") cb = mode, mode = null |
|||
if (typeof cb !== "function") cb = noop |
|||
new OpenReq(path, flags, mode, cb) |
|||
} |
|||
|
|||
function OpenReq(path, flags, mode, cb) { |
|||
this.path = path |
|||
this.flags = flags |
|||
this.mode = mode |
|||
this.cb = cb |
|||
Req.call(this) |
|||
} |
|||
|
|||
util.inherits(OpenReq, Req) |
|||
|
|||
OpenReq.prototype.process = function() { |
|||
originalOpen.call(fs, this.path, this.flags, this.mode, this.done) |
|||
} |
|||
|
|||
var fds = {} |
|||
OpenReq.prototype.done = function(er, fd) { |
|||
debug('open done', er, fd) |
|||
if (fd) |
|||
fds['fd' + fd] = this.path |
|||
Req.prototype.done.call(this, er, fd) |
|||
} |
|||
|
|||
|
|||
var originalReaddir = fs.readdir |
|||
fs.readdir = readdir |
|||
|
|||
function readdir(path, cb) { |
|||
if (typeof cb !== "function") cb = noop |
|||
new ReaddirReq(path, cb) |
|||
} |
|||
|
|||
function ReaddirReq(path, cb) { |
|||
this.path = path |
|||
this.cb = cb |
|||
Req.call(this) |
|||
} |
|||
|
|||
util.inherits(ReaddirReq, Req) |
|||
|
|||
ReaddirReq.prototype.process = function() { |
|||
originalReaddir.call(fs, this.path, this.done) |
|||
} |
|||
|
|||
ReaddirReq.prototype.done = function(er, files) { |
|||
if (files && files.sort) |
|||
files = files.sort() |
|||
Req.prototype.done.call(this, er, files) |
|||
onclose() |
|||
} |
|||
|
|||
|
|||
var originalClose = fs.close |
|||
fs.close = close |
|||
|
|||
function close (fd, cb) { |
|||
debug('close', fd) |
|||
if (typeof cb !== "function") cb = noop |
|||
delete fds['fd' + fd] |
|||
originalClose.call(fs, fd, function(er) { |
|||
onclose() |
|||
cb(er) |
|||
}) |
|||
} |
|||
|
|||
|
|||
var originalCloseSync = fs.closeSync |
|||
fs.closeSync = closeSync |
|||
|
|||
function closeSync (fd) { |
|||
try { |
|||
return originalCloseSync(fd) |
|||
} finally { |
|||
onclose() |
|||
} |
|||
} |
|||
|
|||
|
|||
// Req class
|
|||
function Req () { |
|||
// start processing
|
|||
this.done = this.done.bind(this) |
|||
this.failures = 0 |
|||
this.process() |
|||
} |
|||
|
|||
Req.prototype.done = function (er, result) { |
|||
var tryAgain = false |
|||
if (er) { |
|||
var code = er.code |
|||
var tryAgain = code === "EMFILE" || code === "ENFILE" |
|||
if (process.platform === "win32") |
|||
tryAgain = tryAgain || code === "OK" |
|||
} |
|||
|
|||
if (tryAgain) { |
|||
this.failures ++ |
|||
enqueue(this) |
|||
} else { |
|||
var cb = this.cb |
|||
cb(er, result) |
|||
} |
|||
} |
|||
|
|||
var queue = [] |
|||
|
|||
function enqueue(req) { |
|||
queue.push(req) |
|||
debug('enqueue %d %s', queue.length, req.constructor.name, req) |
|||
} |
|||
|
|||
function onclose() { |
|||
var req = queue.shift() |
|||
if (req) { |
|||
debug('process', req.constructor.name, req) |
|||
req.process() |
|||
} |
|||
} |
@ -1,72 +0,0 @@ |
|||
{ |
|||
"author": { |
|||
"name": "Isaac Z. Schlueter", |
|||
"email": "i@izs.me", |
|||
"url": "http://blog.izs.me" |
|||
}, |
|||
"name": "graceful-fs", |
|||
"description": "A drop-in replacement for fs, making various improvements.", |
|||
"version": "3.0.8", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/isaacs/node-graceful-fs.git" |
|||
}, |
|||
"main": "graceful-fs.js", |
|||
"engines": { |
|||
"node": ">=0.4.0" |
|||
}, |
|||
"directories": { |
|||
"test": "test" |
|||
}, |
|||
"scripts": { |
|||
"test": "tap test/*.js" |
|||
}, |
|||
"keywords": [ |
|||
"fs", |
|||
"module", |
|||
"reading", |
|||
"retry", |
|||
"retries", |
|||
"queue", |
|||
"error", |
|||
"errors", |
|||
"handling", |
|||
"EMFILE", |
|||
"EAGAIN", |
|||
"EINVAL", |
|||
"EPERM", |
|||
"EACCESS" |
|||
], |
|||
"license": "ISC", |
|||
"devDependencies": { |
|||
"mkdirp": "^0.5.0", |
|||
"rimraf": "^2.2.8", |
|||
"tap": "^1.2.0" |
|||
}, |
|||
"gitHead": "45c57aa5e323c35a985a525de6f0c9a6ef59e1f8", |
|||
"bugs": { |
|||
"url": "https://github.com/isaacs/node-graceful-fs/issues" |
|||
}, |
|||
"homepage": "https://github.com/isaacs/node-graceful-fs#readme", |
|||
"_id": "graceful-fs@3.0.8", |
|||
"_shasum": "ce813e725fa82f7e6147d51c9a5ca68270551c22", |
|||
"_from": "graceful-fs@>=3.0.0 <4.0.0", |
|||
"_npmVersion": "2.10.1", |
|||
"_nodeVersion": "2.0.1", |
|||
"_npmUser": { |
|||
"name": "isaacs", |
|||
"email": "isaacs@npmjs.com" |
|||
}, |
|||
"dist": { |
|||
"shasum": "ce813e725fa82f7e6147d51c9a5ca68270551c22", |
|||
"tarball": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.8.tgz" |
|||
}, |
|||
"maintainers": [ |
|||
{ |
|||
"name": "isaacs", |
|||
"email": "i@izs.me" |
|||
} |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.8.tgz", |
|||
"readme": "ERROR: No README data found!" |
|||
} |
@ -1,254 +0,0 @@ |
|||
var fs = require('./fs.js') |
|||
var constants = require('constants') |
|||
|
|||
var origCwd = process.cwd |
|||
var cwd = null |
|||
process.cwd = function() { |
|||
if (!cwd) |
|||
cwd = origCwd.call(process) |
|||
return cwd |
|||
} |
|||
var chdir = process.chdir |
|||
process.chdir = function(d) { |
|||
cwd = null |
|||
chdir.call(process, d) |
|||
} |
|||
|
|||
// (re-)implement some things that are known busted or missing.
|
|||
|
|||
// lchmod, broken prior to 0.6.2
|
|||
// back-port the fix here.
|
|||
if (constants.hasOwnProperty('O_SYMLINK') && |
|||
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { |
|||
fs.lchmod = function (path, mode, callback) { |
|||
callback = callback || noop |
|||
fs.open( path |
|||
, constants.O_WRONLY | constants.O_SYMLINK |
|||
, mode |
|||
, function (err, fd) { |
|||
if (err) { |
|||
callback(err) |
|||
return |
|||
} |
|||
// prefer to return the chmod error, if one occurs,
|
|||
// but still try to close, and report closing errors if they occur.
|
|||
fs.fchmod(fd, mode, function (err) { |
|||
fs.close(fd, function(err2) { |
|||
callback(err || err2) |
|||
}) |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
fs.lchmodSync = function (path, mode) { |
|||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode) |
|||
|
|||
// prefer to return the chmod error, if one occurs,
|
|||
// but still try to close, and report closing errors if they occur.
|
|||
var err, err2 |
|||
try { |
|||
var ret = fs.fchmodSync(fd, mode) |
|||
} catch (er) { |
|||
err = er |
|||
} |
|||
try { |
|||
fs.closeSync(fd) |
|||
} catch (er) { |
|||
err2 = er |
|||
} |
|||
if (err || err2) throw (err || err2) |
|||
return ret |
|||
} |
|||
} |
|||
|
|||
|
|||
// lutimes implementation, or no-op
|
|||
if (!fs.lutimes) { |
|||
if (constants.hasOwnProperty("O_SYMLINK")) { |
|||
fs.lutimes = function (path, at, mt, cb) { |
|||
fs.open(path, constants.O_SYMLINK, function (er, fd) { |
|||
cb = cb || noop |
|||
if (er) return cb(er) |
|||
fs.futimes(fd, at, mt, function (er) { |
|||
fs.close(fd, function (er2) { |
|||
return cb(er || er2) |
|||
}) |
|||
}) |
|||
}) |
|||
} |
|||
|
|||
fs.lutimesSync = function (path, at, mt) { |
|||
var fd = fs.openSync(path, constants.O_SYMLINK) |
|||
, err |
|||
, err2 |
|||
, ret |
|||
|
|||
try { |
|||
var ret = fs.futimesSync(fd, at, mt) |
|||
} catch (er) { |
|||
err = er |
|||
} |
|||
try { |
|||
fs.closeSync(fd) |
|||
} catch (er) { |
|||
err2 = er |
|||
} |
|||
if (err || err2) throw (err || err2) |
|||
return ret |
|||
} |
|||
|
|||
} else if (fs.utimensat && constants.hasOwnProperty("AT_SYMLINK_NOFOLLOW")) { |
|||
// maybe utimensat will be bound soonish?
|
|||
fs.lutimes = function (path, at, mt, cb) { |
|||
fs.utimensat(path, at, mt, constants.AT_SYMLINK_NOFOLLOW, cb) |
|||
} |
|||
|
|||
fs.lutimesSync = function (path, at, mt) { |
|||
return fs.utimensatSync(path, at, mt, constants.AT_SYMLINK_NOFOLLOW) |
|||
} |
|||
|
|||
} else { |
|||
fs.lutimes = function (_a, _b, _c, cb) { process.nextTick(cb) } |
|||
fs.lutimesSync = function () {} |
|||
} |
|||
} |
|||
|
|||
|
|||
// https://github.com/isaacs/node-graceful-fs/issues/4
|
|||
// Chown should not fail on einval or eperm if non-root.
|
|||
// It should not fail on enosys ever, as this just indicates
|
|||
// that a fs doesn't support the intended operation.
|
|||
|
|||
fs.chown = chownFix(fs.chown) |
|||
fs.fchown = chownFix(fs.fchown) |
|||
fs.lchown = chownFix(fs.lchown) |
|||
|
|||
fs.chmod = chownFix(fs.chmod) |
|||
fs.fchmod = chownFix(fs.fchmod) |
|||
fs.lchmod = chownFix(fs.lchmod) |
|||
|
|||
fs.chownSync = chownFixSync(fs.chownSync) |
|||
fs.fchownSync = chownFixSync(fs.fchownSync) |
|||
fs.lchownSync = chownFixSync(fs.lchownSync) |
|||
|
|||
fs.chmodSync = chownFix(fs.chmodSync) |
|||
fs.fchmodSync = chownFix(fs.fchmodSync) |
|||
fs.lchmodSync = chownFix(fs.lchmodSync) |
|||
|
|||
function chownFix (orig) { |
|||
if (!orig) return orig |
|||
return function (target, uid, gid, cb) { |
|||
return orig.call(fs, target, uid, gid, function (er, res) { |
|||
if (chownErOk(er)) er = null |
|||
cb(er, res) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
function chownFixSync (orig) { |
|||
if (!orig) return orig |
|||
return function (target, uid, gid) { |
|||
try { |
|||
return orig.call(fs, target, uid, gid) |
|||
} catch (er) { |
|||
if (!chownErOk(er)) throw er |
|||
} |
|||
} |
|||
} |
|||
|
|||
// ENOSYS means that the fs doesn't support the op. Just ignore
|
|||
// that, because it doesn't matter.
|
|||
//
|
|||
// if there's no getuid, or if getuid() is something other
|
|||
// than 0, and the error is EINVAL or EPERM, then just ignore
|
|||
// it.
|
|||
//
|
|||
// This specific case is a silent failure in cp, install, tar,
|
|||
// and most other unix tools that manage permissions.
|
|||
//
|
|||
// When running as root, or if other types of errors are
|
|||
// encountered, then it's strict.
|
|||
function chownErOk (er) { |
|||
if (!er) |
|||
return true |
|||
|
|||
if (er.code === "ENOSYS") |
|||
return true |
|||
|
|||
var nonroot = !process.getuid || process.getuid() !== 0 |
|||
if (nonroot) { |
|||
if (er.code === "EINVAL" || er.code === "EPERM") |
|||
return true |
|||
} |
|||
|
|||
return false |
|||
} |
|||
|
|||
|
|||
// if lchmod/lchown do not exist, then make them no-ops
|
|||
if (!fs.lchmod) { |
|||
fs.lchmod = function (path, mode, cb) { |
|||
process.nextTick(cb) |
|||
} |
|||
fs.lchmodSync = function () {} |
|||
} |
|||
if (!fs.lchown) { |
|||
fs.lchown = function (path, uid, gid, cb) { |
|||
process.nextTick(cb) |
|||
} |
|||
fs.lchownSync = function () {} |
|||
} |
|||
|
|||
|
|||
|
|||
// on Windows, A/V software can lock the directory, causing this
|
|||
// to fail with an EACCES or EPERM if the directory contains newly
|
|||
// created files. Try again on failure, for up to 1 second.
|
|||
if (process.platform === "win32") { |
|||
var rename_ = fs.rename |
|||
fs.rename = function rename (from, to, cb) { |
|||
var start = Date.now() |
|||
rename_(from, to, function CB (er) { |
|||
if (er |
|||
&& (er.code === "EACCES" || er.code === "EPERM") |
|||
&& Date.now() - start < 1000) { |
|||
return rename_(from, to, CB) |
|||
} |
|||
if(cb) cb(er) |
|||
}) |
|||
} |
|||
} |
|||
|
|||
|
|||
// if read() returns EAGAIN, then just try it again.
|
|||
var read = fs.read |
|||
fs.read = function (fd, buffer, offset, length, position, callback_) { |
|||
var callback |
|||
if (callback_ && typeof callback_ === 'function') { |
|||
var eagCounter = 0 |
|||
callback = function (er, _, __) { |
|||
if (er && er.code === 'EAGAIN' && eagCounter < 10) { |
|||
eagCounter ++ |
|||
return read.call(fs, fd, buffer, offset, length, position, callback) |
|||
} |
|||
callback_.apply(this, arguments) |
|||
} |
|||
} |
|||
return read.call(fs, fd, buffer, offset, length, position, callback) |
|||
} |
|||
|
|||
var readSync = fs.readSync |
|||
fs.readSync = function (fd, buffer, offset, length, position) { |
|||
var eagCounter = 0 |
|||
while (true) { |
|||
try { |
|||
return readSync.call(fs, fd, buffer, offset, length, position) |
|||
} catch (er) { |
|||
if (er.code === 'EAGAIN' && eagCounter < 10) { |
|||
eagCounter ++ |
|||
continue |
|||
} |
|||
throw er |
|||
} |
|||
} |
|||
} |
@ -1,69 +0,0 @@ |
|||
var test = require('tap').test |
|||
var fs = require('../') |
|||
|
|||
test('open lots of stuff', function (t) { |
|||
// Get around EBADF from libuv by making sure that stderr is opened
|
|||
// Otherwise Darwin will refuse to give us a FD for stderr!
|
|||
process.stderr.write('') |
|||
|
|||
// How many parallel open()'s to do
|
|||
var n = 1024 |
|||
var opens = 0 |
|||
var fds = [] |
|||
var going = true |
|||
var closing = false |
|||
var doneCalled = 0 |
|||
|
|||
for (var i = 0; i < n; i++) { |
|||
go() |
|||
} |
|||
|
|||
function go() { |
|||
opens++ |
|||
fs.open(__filename, 'r', function (er, fd) { |
|||
if (er) throw er |
|||
fds.push(fd) |
|||
if (going) go() |
|||
}) |
|||
} |
|||
|
|||
// should hit ulimit pretty fast
|
|||
setTimeout(function () { |
|||
going = false |
|||
t.equal(opens - fds.length, n) |
|||
done() |
|||
}, 100) |
|||
|
|||
|
|||
function done () { |
|||
if (closing) return |
|||
doneCalled++ |
|||
|
|||
if (fds.length === 0) { |
|||
console.error('done called %d times', doneCalled) |
|||
// First because of the timeout
|
|||
// Then to close the fd's opened afterwards
|
|||
// Then this time, to complete.
|
|||
// Might take multiple passes, depending on CPU speed
|
|||
// and ulimit, but at least 3 in every case.
|
|||
t.ok(doneCalled >= 2) |
|||
return t.end() |
|||
} |
|||
|
|||
closing = true |
|||
setTimeout(function () { |
|||
// console.error('do closing again')
|
|||
closing = false |
|||
done() |
|||
}, 100) |
|||
|
|||
// console.error('closing time')
|
|||
var closes = fds.slice(0) |
|||
fds.length = 0 |
|||
closes.forEach(function (fd) { |
|||
fs.close(fd, function (er) { |
|||
if (er) throw er |
|||
}) |
|||
}) |
|||
} |
|||
}) |
@ -1,39 +0,0 @@ |
|||
var test = require('tap').test |
|||
var fs = require('../graceful-fs.js') |
|||
|
|||
test('graceful fs is monkeypatched fs', function (t) { |
|||
t.equal(fs, require('../fs.js')) |
|||
t.end() |
|||
}) |
|||
|
|||
test('open an existing file works', function (t) { |
|||
var fd = fs.openSync(__filename, 'r') |
|||
fs.closeSync(fd) |
|||
fs.open(__filename, 'r', function (er, fd) { |
|||
if (er) throw er |
|||
fs.close(fd, function (er) { |
|||
if (er) throw er |
|||
t.pass('works') |
|||
t.end() |
|||
}) |
|||
}) |
|||
}) |
|||
|
|||
test('open a non-existing file throws', function (t) { |
|||
var er |
|||
try { |
|||
var fd = fs.openSync('this file does not exist', 'r') |
|||
} catch (x) { |
|||
er = x |
|||
} |
|||
t.ok(er, 'should throw') |
|||
t.notOk(fd, 'should not get an fd') |
|||
t.equal(er.code, 'ENOENT') |
|||
|
|||
fs.open('neither does this file', 'r', function (er, fd) { |
|||
t.ok(er, 'should throw') |
|||
t.notOk(fd, 'should not get an fd') |
|||
t.equal(er.code, 'ENOENT') |
|||
t.end() |
|||
}) |
|||
}) |
@ -1,20 +0,0 @@ |
|||
var test = require("tap").test |
|||
var fs = require("../fs.js") |
|||
|
|||
var readdir = fs.readdir |
|||
fs.readdir = function(path, cb) { |
|||
process.nextTick(function() { |
|||
cb(null, ["b", "z", "a"]) |
|||
}) |
|||
} |
|||
|
|||
var g = require("../") |
|||
|
|||
test("readdir reorder", function (t) { |
|||
g.readdir("whatevers", function (er, files) { |
|||
if (er) |
|||
throw er |
|||
t.same(files, [ "a", "b", "z" ]) |
|||
t.end() |
|||
}) |
|||
}) |
@ -1,47 +0,0 @@ |
|||
var fs = require('../'); |
|||
var rimraf = require('rimraf'); |
|||
var mkdirp = require('mkdirp'); |
|||
var test = require('tap').test; |
|||
var p = require('path').resolve(__dirname, 'files'); |
|||
|
|||
process.chdir(__dirname) |
|||
|
|||
// Make sure to reserve the stderr fd
|
|||
process.stderr.write(''); |
|||
|
|||
var num = 4097; |
|||
var paths = new Array(num); |
|||
|
|||
test('make files', function (t) { |
|||
rimraf.sync(p); |
|||
mkdirp.sync(p); |
|||
|
|||
for (var i = 0; i < num; ++i) { |
|||
paths[i] = 'files/file-' + i; |
|||
fs.writeFileSync(paths[i], 'content'); |
|||
} |
|||
|
|||
t.end(); |
|||
}) |
|||
|
|||
test('read files', function (t) { |
|||
// now read them
|
|||
var done = 0; |
|||
for (var i = 0; i < num; ++i) { |
|||
fs.readFile(paths[i], function(err, data) { |
|||
if (err) |
|||
throw err; |
|||
|
|||
++done; |
|||
if (done === num) { |
|||
t.pass('success'); |
|||
t.end() |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
test('cleanup', function (t) { |
|||
rimraf.sync(p); |
|||
t.end(); |
|||
}); |
@ -1,4 +0,0 @@ |
|||
node_modules/ |
|||
coverage/ |
|||
.nyc_output/ |
|||
nyc_output/ |
@ -1,5 +0,0 @@ |
|||
language: node_js |
|||
node_js: |
|||
- '0.10' |
|||
- '0.12' |
|||
- 'iojs' |
@ -1,15 +0,0 @@ |
|||
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. |
@ -1,24 +0,0 @@ |
|||
files = semver.browser.js \
|
|||
semver.min.js \
|
|||
semver.browser.js.gz \
|
|||
semver.min.js.gz |
|||
|
|||
all: $(files) |
|||
|
|||
clean: |
|||
rm -f $(files) |
|||
|
|||
semver.browser.js: head.js.txt semver.js foot.js.txt |
|||
( cat head.js.txt; \
|
|||
cat semver.js | \
|
|||
egrep -v '^ *\/\* nomin \*\/' | \
|
|||
perl -pi -e 's/debug\([^\)]+\)//g'; \
|
|||
cat foot.js.txt ) > semver.browser.js |
|||
|
|||
semver.min.js: semver.browser.js |
|||
uglifyjs -m <semver.browser.js >semver.min.js |
|||
|
|||
%.gz: % |
|||
gzip --stdout -9 <$< >$@ |
|||
|
|||
.PHONY: all clean |
@ -1,303 +0,0 @@ |
|||
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. |
@ -1,133 +0,0 @@ |
|||
#!/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")) |
|||
} |
@ -1,6 +0,0 @@ |
|||
|
|||
})( |
|||
typeof exports === 'object' ? exports : |
|||
typeof define === 'function' && define.amd ? {} : |
|||
semver = {} |
|||
); |
@ -1 +0,0 @@ |
|||
;(function(exports) { |
@ -1,55 +0,0 @@ |
|||
{ |
|||
"name": "semver", |
|||
"version": "4.3.6", |
|||
"description": "The semantic version parser used by npm.", |
|||
"main": "semver.js", |
|||
"browser": "semver.browser.js", |
|||
"min": "semver.min.js", |
|||
"scripts": { |
|||
"test": "tap test/*.js", |
|||
"prepublish": "make" |
|||
}, |
|||
"devDependencies": { |
|||
"tap": "^1.2.0", |
|||
"uglify-js": "~2.3.6" |
|||
}, |
|||
"license": "ISC", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/npm/node-semver.git" |
|||
}, |
|||
"bin": { |
|||
"semver": "./bin/semver" |
|||
}, |
|||
"gitHead": "63c48296ca5da3ba6a88c743bb8c92effc789811", |
|||
"bugs": { |
|||
"url": "https://github.com/npm/node-semver/issues" |
|||
}, |
|||
"homepage": "https://github.com/npm/node-semver#readme", |
|||
"_id": "semver@4.3.6", |
|||
"_shasum": "300bc6e0e86374f7ba61068b5b1ecd57fc6532da", |
|||
"_from": "semver@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0||>=4.0.0 <5.0.0", |
|||
"_npmVersion": "2.10.1", |
|||
"_nodeVersion": "2.0.1", |
|||
"_npmUser": { |
|||
"name": "isaacs", |
|||
"email": "isaacs@npmjs.com" |
|||
}, |
|||
"dist": { |
|||
"shasum": "300bc6e0e86374f7ba61068b5b1ecd57fc6532da", |
|||
"tarball": "http://registry.npmjs.org/semver/-/semver-4.3.6.tgz" |
|||
}, |
|||
"maintainers": [ |
|||
{ |
|||
"name": "isaacs", |
|||
"email": "isaacs@npmjs.com" |
|||
}, |
|||
{ |
|||
"name": "othiym23", |
|||
"email": "ogd@aoaioxxysz.net" |
|||
} |
|||
], |
|||
"directories": {}, |
|||
"_resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", |
|||
"readme": "ERROR: No README data found!" |
|||
} |
File diff suppressed because it is too large
Binary file not shown.
File diff suppressed because it is too large
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -1,15 +0,0 @@ |
|||
var tap = require('tap'); |
|||
var test = tap.test; |
|||
|
|||
test('amd', function(t) { |
|||
global.define = define; |
|||
define.amd = true; |
|||
var defined = null; |
|||
function define(stuff) { |
|||
defined = stuff; |
|||
} |
|||
var fromRequire = require('../'); |
|||
t.ok(defined, 'amd function called'); |
|||
t.equal(fromRequire, defined, 'amd stuff same as require stuff'); |
|||
t.end(); |
|||
}); |
@ -1,31 +0,0 @@ |
|||
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() |
|||
}) |
@ -1,29 +0,0 @@ |
|||
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(); |
|||
}); |
@ -1,173 +0,0 @@ |
|||
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(); |
|||
}); |
@ -1,685 +0,0 @@ |
|||
'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', 'dev'], |
|||
['1.2.0-1', 'prepatch', '1.2.1-dev.0', 'dev'], |
|||
['1.2.0', 'preminor', '1.3.0-dev.0', 'dev'], |
|||
['1.2.3-1', 'preminor', '1.3.0-dev.0', 'dev'], |
|||
['1.2.0', 'premajor', '2.0.0-dev.0', 'dev'], |
|||
['1.2.3-1', 'premajor', '2.0.0-dev.0', 'dev'], |
|||
['1.2.0-1', 'minor', '1.2.0', 'dev'], |
|||
['1.0.0-1', 'major', '1.0.0', '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); |
|||
}); |
|||
|
|||
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(); |
|||
}); |
@ -1,181 +0,0 @@ |
|||
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(); |
|||
}); |
@ -1,72 +0,0 @@ |
|||
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(); |
|||
}); |
@ -1,18 +0,0 @@ |
|||
var tap = require('tap'); |
|||
var test = tap.test; |
|||
|
|||
test('no module system', function(t) { |
|||
var fs = require('fs'); |
|||
var vm = require('vm'); |
|||
var head = fs.readFileSync(require.resolve('../head.js.txt'), 'utf8'); |
|||
var src = fs.readFileSync(require.resolve('../'), 'utf8'); |
|||
var foot = fs.readFileSync(require.resolve('../foot.js.txt'), 'utf8'); |
|||
vm.runInThisContext(head + src + foot, 'semver.js'); |
|||
|
|||
// just some basic poking to see if it did some stuff
|
|||
t.type(global.semver, 'object'); |
|||
t.type(global.semver.SemVer, 'function'); |
|||
t.type(global.semver.Range, 'function'); |
|||
t.ok(global.semver.satisfies('1.2.3', '1.2')); |
|||
t.end(); |
|||
}); |
@ -0,0 +1,143 @@ |
|||
#!/bin/bash |
|||
|
|||
#set -e |
|||
|
|||
test_node_versions="0.8.28 0.10.40 0.12.7" |
|||
test_iojs_versions="1.8.4 2.4.0 3.3.0" |
|||
|
|||
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
|||
dot_node_gyp=${__dirname}/.node-gyp/ |
|||
|
|||
# borrows from https://github.com/rvagg/dnt/ |
|||
|
|||
# Simple setup function for a container: |
|||
# setup_container(image id, base image, commands to run to set up) |
|||
setup_container() { |
|||
local container_id="$1" |
|||
local base_container="$2" |
|||
local run_cmd="$3" |
|||
|
|||
# Does this image exist? If yes, ignore |
|||
docker inspect "$container_id" &> /dev/null |
|||
if [[ $? -eq 0 ]]; then |
|||
echo "Found existing container [$container_id]" |
|||
else |
|||
# No such image, so make it |
|||
echo "Did not find container [$container_id], creating..." |
|||
docker run -i $base_container /bin/bash -c "$run_cmd" |
|||
sleep 2 |
|||
docker commit $(docker ps -l -q) $container_id |
|||
fi |
|||
} |
|||
|
|||
# Run tests inside each of the versioned containers, copy cwd into npm's copy of node-gyp |
|||
# so it'll be invoked by npm when a compile is needed |
|||
# run_tests(version, test-commands) |
|||
run_tests() { |
|||
local version="$1" |
|||
local run_cmd="$2" |
|||
|
|||
run_cmd="rsync -aAXx --delete --exclude .git --exclude build /node-gyp-src/ /usr/lib/node_modules/npm/node_modules/node-gyp/; |
|||
/bin/su -s /bin/bash node-gyp -c 'cd && ${run_cmd}'" |
|||
|
|||
rm -rf $dot_node_gyp |
|||
|
|||
docker run \ |
|||
--rm -i \ |
|||
-v ~/.npm/:/node-gyp/.npm/ \ |
|||
-v ${dot_node_gyp}:/node-gyp/.node-gyp/ \ |
|||
-v $(pwd):/node-gyp-src/:ro \ |
|||
node-gyp-test/${version} /bin/bash -c "${run_cmd}" |
|||
} |
|||
|
|||
# A base image with build tools and a user account |
|||
setup_container "node-gyp-test/base" "ubuntu:14.04" " |
|||
apt-get update && |
|||
apt-get install -y build-essential python git rsync curl && |
|||
adduser --gecos node-gyp --home /node-gyp/ --disabled-login node-gyp && |
|||
echo "node-gyp:node-gyp" | chpasswd |
|||
" |
|||
|
|||
# An image on top of the base containing clones of repos we want to use for testing |
|||
setup_container "node-gyp-test/clones" "node-gyp-test/base" " |
|||
cd /node-gyp/ && git clone https://github.com/justmoon/node-bignum.git && |
|||
cd /node-gyp/ && git clone https://github.com/bnoordhuis/node-buffertools.git && |
|||
chown -R node-gyp.node-gyp /node-gyp/ |
|||
" |
|||
|
|||
# An image for each of the node versions we want to test with that version installed and the latest npm |
|||
for v in $test_node_versions; do |
|||
setup_container "node-gyp-test/${v}" "node-gyp-test/clones" " |
|||
curl -sL https://nodejs.org/dist/v${v}/node-v${v}-linux-x64.tar.gz | tar -zxv --strip-components=1 -C /usr/ && |
|||
npm install npm@latest -g && |
|||
node -v && npm -v |
|||
" |
|||
done |
|||
|
|||
# An image for each of the io.js versions we want to test with that version installed and the latest npm |
|||
for v in $test_iojs_versions; do |
|||
setup_container "node-gyp-test/${v}" "node-gyp-test/clones" " |
|||
curl -sL https://iojs.org/dist/v${v}/iojs-v${v}-linux-x64.tar.gz | tar -zxv --strip-components=1 -C /usr/ && |
|||
npm install npm@latest -g && |
|||
node -v && npm -v |
|||
" |
|||
done |
|||
|
|||
# Run the tests for all of the test images we've created, |
|||
# we should see node-gyp doing its download, configure and run thing |
|||
# _NOTE: bignum doesn't compile on 0.8 currently so it'll fail for that version only_ |
|||
for v in $test_node_versions $test_iojs_versions; do |
|||
run_tests $v " |
|||
cd node-buffertools && npm install --loglevel=info && npm test && cd |
|||
" |
|||
# removed for now, too noisy: cd node-bignum && npm install --loglevel=info && npm test |
|||
done |
|||
|
|||
# Test use of --target=x.y.z to compile against alternate versions |
|||
test_download_node_version() { |
|||
local run_with_ver="$1" |
|||
local expected_dir="$2" |
|||
local expected_ver="$3" |
|||
run_tests $run_with_ver "cd node-buffertools && npm install --loglevel=info --target=${expected_ver}" |
|||
local node_ver=$(cat "${dot_node_gyp}${expected_dir}/node_version.h" | grep '#define NODE_\w*_VERSION [0-9]*$') |
|||
node_ver=$(echo $node_ver | sed 's/#define NODE_[A-Z]*_VERSION //g' | sed 's/ /./g') |
|||
if [ "X$(echo $node_ver)" != "X${expected_ver}" ]; then |
|||
echo "Did not download v${expected_ver} using --target, instead got: $(echo $node_ver)" |
|||
exit 1 |
|||
fi |
|||
echo "Verified correct download of [v${node_ver}]" |
|||
} |
|||
|
|||
test_download_node_version "0.12.7" "0.10.30/src" "0.10.30" |
|||
test_download_node_version "3.3.0" "iojs-1.8.4/src" "1.8.4" |
|||
# should download the headers file |
|||
test_download_node_version "3.3.0" "iojs-3.2.0/include/node" "3.2.0" |
|||
|
|||
# TODO: test --dist-url by starting up a localhost server and serving up tarballs |
|||
|
|||
# testing --dist-url, using simple-proxy.js to make localhost work as a distribution |
|||
# point for tarballs |
|||
# we can test whether it uses the proxy because after 2 connections the proxy will |
|||
# die and therefore should not be running at the end of the test, `nc` can tell us this |
|||
run_tests "3.3.0" " |
|||
(node /node-gyp-src/test/simple-proxy.js 8080 /foobar/ https://iojs.org/dist/ &) && |
|||
cd node-buffertools && |
|||
/node-gyp-src/bin/node-gyp.js --loglevel=info --dist-url=http://localhost:8080/foobar/ rebuild && |
|||
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" |
|||
" |
|||
|
|||
run_tests "3.3.0" " |
|||
(node /node-gyp-src/test/simple-proxy.js 8080 /doobar/ https://iojs.org/dist/ &) && |
|||
cd node-buffertools && |
|||
NVM_IOJS_ORG_MIRROR=http://localhost:8080/doobar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild && |
|||
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" |
|||
" |
|||
|
|||
run_tests "0.12.7" " |
|||
(node /node-gyp-src/test/simple-proxy.js 8080 /boombar/ https://nodejs.org/dist/ &) && |
|||
cd node-buffertools && |
|||
NVM_NODEJS_ORG_MIRROR=http://localhost:8080/boombar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild && |
|||
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\" |
|||
" |
|||
|
|||
rm -rf $dot_node_gyp |
@ -0,0 +1,24 @@ |
|||
var http = require('http') |
|||
, https = require('https') |
|||
, server = http.createServer(handler) |
|||
, port = +process.argv[2] |
|||
, prefix = process.argv[3] |
|||
, upstream = process.argv[4] |
|||
, calls = 0 |
|||
|
|||
server.listen(port) |
|||
|
|||
function handler (req, res) { |
|||
if (req.url.indexOf(prefix) != 0) |
|||
throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']') |
|||
|
|||
var upstreamUrl = upstream + req.url.substring(prefix.length) |
|||
console.log(req.url + ' -> ' + upstreamUrl) |
|||
https.get(upstreamUrl, function (ures) { |
|||
ures.on('end', function () { |
|||
if (++calls == 2) |
|||
server.close() |
|||
}) |
|||
ures.pipe(res) |
|||
}) |
|||
} |
@ -0,0 +1,450 @@ |
|||
var test = require('tape') |
|||
var processRelease = require('../lib/process-release') |
|||
|
|||
test('test process release - process.version = 0.8.20', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v0.8.20', null) |
|||
|
|||
t.equal(release.semver.version, '0.8.20') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '0.8.20', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/dist/v0.8.20/', |
|||
tarballUrl: 'https://nodejs.org/dist/v0.8.20/node-v0.8.20.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/dist/v0.8.20/SHASUMS256.txt', |
|||
versionDir: '0.8.20', |
|||
libUrl32: 'https://nodejs.org/dist/v0.8.20/node.lib', |
|||
libUrl64: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', |
|||
libPath32: 'node.lib', |
|||
libPath64: 'x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.version = 0.10.21', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v0.10.21', null) |
|||
|
|||
t.equal(release.semver.version, '0.10.21') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '0.10.21', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/dist/v0.10.21/', |
|||
tarballUrl: 'https://nodejs.org/dist/v0.10.21/node-v0.10.21.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/dist/v0.10.21/SHASUMS256.txt', |
|||
versionDir: '0.10.21', |
|||
libUrl32: 'https://nodejs.org/dist/v0.10.21/node.lib', |
|||
libUrl64: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', |
|||
libPath32: 'node.lib', |
|||
libPath64: 'x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.version = 0.12.22', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v0.12.22', null) |
|||
|
|||
t.equal(release.semver.version, '0.12.22') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '0.12.22', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/dist/v0.12.22/', |
|||
tarballUrl: 'https://nodejs.org/dist/v0.12.22/node-v0.12.22.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/dist/v0.12.22/SHASUMS256.txt', |
|||
versionDir: '0.12.22', |
|||
libUrl32: 'https://nodejs.org/dist/v0.12.22/node.lib', |
|||
libUrl64: 'https://nodejs.org/dist/v0.12.22/x64/node.lib', |
|||
libPath32: 'node.lib', |
|||
libPath64: 'x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.1.23', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v4.1.23', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.1.23') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.1.23', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/dist/v4.1.23/', |
|||
tarballUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/dist/v4.1.23/SHASUMS256.txt', |
|||
versionDir: '4.1.23', |
|||
libUrl32: 'https://nodejs.org/dist/v4.1.23/win-x86/node.lib', |
|||
libUrl64: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.1.23 / corp build', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v4.1.23', { |
|||
name: 'node', |
|||
headersUrl: 'https://some.custom.location/node-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.1.23') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.1.23', |
|||
name: 'node', |
|||
baseUrl: 'https://some.custom.location/', |
|||
tarballUrl: 'https://some.custom.location/node-v4.1.23-headers.tar.gz', |
|||
shasumsUrl: 'https://some.custom.location/SHASUMS256.txt', |
|||
versionDir: '4.1.23', |
|||
libUrl32: 'https://some.custom.location/win-x86/node.lib', |
|||
libUrl64: 'https://some.custom.location/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.version = 1.8.4', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v1.8.4', null) |
|||
|
|||
t.equal(release.semver.version, '1.8.4') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '1.8.4', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v1.8.4/', |
|||
tarballUrl: 'https://iojs.org/download/release/v1.8.4/iojs-v1.8.4.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v1.8.4/SHASUMS256.txt', |
|||
versionDir: 'iojs-1.8.4', |
|||
libUrl32: 'https://iojs.org/download/release/v1.8.4/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v1.8.4/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ iojs@3.2.24', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v3.2.24', { |
|||
name: 'io.js', |
|||
headersUrl: 'https://iojs.org/download/release/v3.2.24/iojs-v3.2.24-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '3.2.24') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '3.2.24', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v3.2.24/', |
|||
tarballUrl: 'https://iojs.org/download/release/v3.2.24/iojs-v3.2.24-headers.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v3.2.24/SHASUMS256.txt', |
|||
versionDir: 'iojs-3.2.24', |
|||
libUrl32: 'https://iojs.org/download/release/v3.2.24/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v3.2.24/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ iojs@3.2.11 +libUrl32', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v3.2.11', { |
|||
name: 'io.js', |
|||
headersUrl: 'https://iojs.org/download/release/v3.2.11/iojs-v3.2.11-headers.tar.gz', |
|||
libUrl: 'https://iojs.org/download/release/v3.2.11/win-x86/iojs.lib' // custom
|
|||
}) |
|||
|
|||
t.equal(release.semver.version, '3.2.11') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '3.2.11', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v3.2.11/', |
|||
tarballUrl: 'https://iojs.org/download/release/v3.2.11/iojs-v3.2.11-headers.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v3.2.11/SHASUMS256.txt', |
|||
versionDir: 'iojs-3.2.11', |
|||
libUrl32: 'https://iojs.org/download/release/v3.2.11/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v3.2.11/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ iojs@3.2.101 +libUrl64', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v3.2.101', { |
|||
name: 'io.js', |
|||
headersUrl: 'https://iojs.org/download/release/v3.2.101/iojs-v3.2.101-headers.tar.gz', |
|||
libUrl: 'https://iojs.org/download/release/v3.2.101/win-x64/iojs.lib' // custom
|
|||
}) |
|||
|
|||
t.equal(release.semver.version, '3.2.101') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '3.2.101', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v3.2.101/', |
|||
tarballUrl: 'https://iojs.org/download/release/v3.2.101/iojs-v3.2.101-headers.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v3.2.101/SHASUMS256.txt', |
|||
versionDir: 'iojs-3.2.101', |
|||
libUrl32: 'https://iojs.org/download/release/v3.2.101/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v3.2.101/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ iojs@3.3.0 - borked win-ia32', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v3.2.101', { |
|||
name: 'io.js', |
|||
headersUrl: 'https://iojs.org/download/release/v3.2.101/iojs-v3.2.101-headers.tar.gz', |
|||
libUrl: 'https://iojs.org/download/release/v3.2.101/win-ia32/iojs.lib' // custom
|
|||
}) |
|||
|
|||
t.equal(release.semver.version, '3.2.101') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '3.2.101', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v3.2.101/', |
|||
tarballUrl: 'https://iojs.org/download/release/v3.2.101/iojs-v3.2.101-headers.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v3.2.101/SHASUMS256.txt', |
|||
versionDir: 'iojs-3.2.101', |
|||
libUrl32: 'https://iojs.org/download/release/v3.2.101/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v3.2.101/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.1.23 --target=0.10.40', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: { target: '0.10.40' } }, 'v4.1.23', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '0.10.40') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '0.10.40', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/dist/v0.10.40/', |
|||
tarballUrl: 'https://nodejs.org/dist/v0.10.40/node-v0.10.40.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/dist/v0.10.40/SHASUMS256.txt', |
|||
versionDir: '0.10.40', |
|||
libUrl32: 'https://nodejs.org/dist/v0.10.40/node.lib', |
|||
libUrl64: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', |
|||
libPath32: 'node.lib', |
|||
libPath64: 'x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.1.23 --target=1.8.4', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: { target: '1.8.4' } }, 'v4.1.23', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '1.8.4') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '1.8.4', |
|||
name: 'iojs', |
|||
baseUrl: 'https://iojs.org/download/release/v1.8.4/', |
|||
tarballUrl: 'https://iojs.org/download/release/v1.8.4/iojs-v1.8.4.tar.gz', |
|||
shasumsUrl: 'https://iojs.org/download/release/v1.8.4/SHASUMS256.txt', |
|||
versionDir: 'iojs-1.8.4', |
|||
libUrl32: 'https://iojs.org/download/release/v1.8.4/win-x86/iojs.lib', |
|||
libUrl64: 'https://iojs.org/download/release/v1.8.4/win-x64/iojs.lib', |
|||
libPath32: 'win-x86/iojs.lib', |
|||
libPath64: 'win-x64/iojs.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.1.23 --dist-url=https://foo.bar/baz', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: { 'dist-url': 'https://foo.bar/baz' } }, 'v4.1.23', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.1.23') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.1.23', |
|||
name: 'node', |
|||
baseUrl: 'https://foo.bar/baz/v4.1.23/', |
|||
tarballUrl: 'https://foo.bar/baz/v4.1.23/node-v4.1.23-headers.tar.gz', |
|||
shasumsUrl: 'https://foo.bar/baz/v4.1.23/SHASUMS256.txt', |
|||
versionDir: '4.1.23', |
|||
libUrl32: 'https://foo.bar/baz/v4.1.23/win-x86/node.lib', |
|||
libUrl64: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ frankenstein@4.1.23', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v4.1.23', { |
|||
name: 'frankenstein', |
|||
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.1.23') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.1.23', |
|||
name: 'frankenstein', |
|||
baseUrl: 'https://frankensteinjs.org/dist/v4.1.23/', |
|||
tarballUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23-headers.tar.gz', |
|||
shasumsUrl: 'https://frankensteinjs.org/dist/v4.1.23/SHASUMS256.txt', |
|||
versionDir: 'frankenstein-4.1.23', |
|||
libUrl32: 'https://frankensteinjs.org/dist/v4.1.23/win-x86/frankenstein.lib', |
|||
libUrl64: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', |
|||
libPath32: 'win-x86/frankenstein.lib', |
|||
libPath64: 'win-x64/frankenstein.lib' |
|||
}) |
|||
}) |
|||
|
|||
|
|||
test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: { 'dist-url': 'http://foo.bar/baz/' } }, 'v4.1.23', { |
|||
name: 'frankenstein', |
|||
headersUrl: 'https://frankensteinjs.org/dist/v4.1.23/frankenstein-v4.1.23.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.1.23') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.1.23', |
|||
name: 'frankenstein', |
|||
baseUrl: 'http://foo.bar/baz/v4.1.23/', |
|||
tarballUrl: 'http://foo.bar/baz/v4.1.23/frankenstein-v4.1.23-headers.tar.gz', |
|||
shasumsUrl: 'http://foo.bar/baz/v4.1.23/SHASUMS256.txt', |
|||
versionDir: 'frankenstein-4.1.23', |
|||
libUrl32: 'http://foo.bar/baz/v4.1.23/win-x86/frankenstein.lib', |
|||
libUrl64: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', |
|||
libPath32: 'win-x86/frankenstein.lib', |
|||
libPath64: 'win-x64/frankenstein.lib' |
|||
}) |
|||
}) |
|||
|
|||
test('test process release - process.release ~ node@4.0.0-rc.4', function (t) { |
|||
t.plan(2) |
|||
|
|||
var release = processRelease([], { opts: {} }, 'v4.0.0-rc.4', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.0.0-rc.4') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.0.0-rc.4', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/', |
|||
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', |
|||
versionDir: '4.0.0-rc.4', |
|||
libUrl32: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', |
|||
libUrl64: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
|
|||
test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function (t) { |
|||
t.plan(2) |
|||
|
|||
// note the missing 'v' on the arg, it should normalise when checking
|
|||
// whether we're on the default or not
|
|||
var release = processRelease([ '4.0.0-rc.4' ], { opts: {} }, 'v4.0.0-rc.4', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.0.0-rc.4') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.0.0-rc.4', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/', |
|||
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', |
|||
versionDir: '4.0.0-rc.4', |
|||
libUrl32: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', |
|||
libUrl64: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
|||
|
|||
|
|||
test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) { |
|||
t.plan(2) |
|||
|
|||
// additional arguments can be passed in on the commandline that should be ignored if they
|
|||
// are not specifying a valid version @ position 0
|
|||
var release = processRelease([ 'this is no version!' ], { opts: {} }, 'v4.0.0-rc.4', { |
|||
name: 'node', |
|||
headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' |
|||
}) |
|||
|
|||
t.equal(release.semver.version, '4.0.0-rc.4') |
|||
delete release.semver |
|||
|
|||
t.deepEqual(release, { |
|||
version: '4.0.0-rc.4', |
|||
name: 'node', |
|||
baseUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/', |
|||
tarballUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz', |
|||
shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', |
|||
versionDir: '4.0.0-rc.4', |
|||
libUrl32: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', |
|||
libUrl64: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', |
|||
libPath32: 'win-x86/node.lib', |
|||
libPath64: 'win-x64/node.lib' |
|||
}) |
|||
}) |
Loading…
Reference in new issue