diff options
Diffstat (limited to 'node_modules/semver/semver.js')
-rw-r--r-- | node_modules/semver/semver.js | 62 |
1 files changed, 42 insertions, 20 deletions
diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js index 8b5b93f96..22673fdd1 100644 --- a/node_modules/semver/semver.js +++ b/node_modules/semver/semver.js @@ -355,35 +355,35 @@ SemVer.prototype.comparePre = function(other) { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. -SemVer.prototype.inc = function(release) { +SemVer.prototype.inc = function(release, identifier) { switch (release) { case 'premajor': this.prerelease.length = 0; this.patch = 0; this.minor = 0; this.major++; - this.inc('pre'); + this.inc('pre', identifier); break; case 'preminor': this.prerelease.length = 0; this.patch = 0; this.minor++; - this.inc('pre'); + this.inc('pre', identifier); break; case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0; - this.inc('patch'); - this.inc('pre'); + this.inc('patch', identifier); + this.inc('pre', identifier); break; // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) - this.inc('patch'); - this.inc('pre'); + this.inc('patch', identifier); + this.inc('pre', identifier); break; case 'major': @@ -417,7 +417,7 @@ SemVer.prototype.inc = function(release) { this.prerelease = []; break; // This probably shouldn't be used publicly. - // 1.0.0 "pre" would become 1.0.0 which is the wrong direction. + // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. case 'pre': if (this.prerelease.length === 0) this.prerelease = [0]; @@ -432,6 +432,15 @@ SemVer.prototype.inc = function(release) { if (i === -1) // didn't increment anything this.prerelease.push(0); } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) + this.prerelease = [identifier, 0]; + } else + this.prerelease = [identifier, 0]; + } break; default: @@ -442,9 +451,14 @@ SemVer.prototype.inc = function(release) { }; exports.inc = inc; -function inc(version, release, loose) { +function inc(version, release, loose, identifier) { + if (typeof(loose) === 'string') { + identifier = loose; + loose = undefined; + } + try { - return new SemVer(version, loose).inc(release).version; + return new SemVer(version, loose).inc(release, identifier).version; } catch (er) { return null; } @@ -856,10 +870,16 @@ function replaceXRange(comp, loose) { if (gtlt === '=' && anyX) gtlt = ''; - if (gtlt && anyX) { + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0'; + } else { + // nothing is forbidden + ret = '*'; + } + } else if (gtlt && anyX) { // replace X with 0 - if (xM) - M = 0; if (xm) m = 0; if (xp) @@ -870,9 +890,7 @@ function replaceXRange(comp, loose) { // >1.2 => >=1.3.0 // >1.2.3 => >= 1.2.4 gtlt = '>='; - if (xM) { - // no change - } else if (xm) { + if (xm) { M = +M + 1; m = 0; p = 0; @@ -880,13 +898,17 @@ function replaceXRange(comp, loose) { m = +m + 1; p = 0; } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) + M = +M + 1 + else + m = +m + 1 } - ret = gtlt + M + '.' + m + '.' + p; - } else if (xM) { - // allow any - ret = '*'; } else if (xm) { ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'; } else if (xp) { |