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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/semver/semver.js')
-rw-r--r--node_modules/semver/semver.js44
1 files changed, 20 insertions, 24 deletions
diff --git a/node_modules/semver/semver.js b/node_modules/semver/semver.js
index a7385b41c..2939331c8 100644
--- a/node_modules/semver/semver.js
+++ b/node_modules/semver/semver.js
@@ -366,6 +366,10 @@ SemVer.prototype.inc = function(release) {
this.inc('pre');
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');
break;
@@ -558,6 +562,9 @@ Comparator.prototype.parse = function(comp) {
throw new TypeError('Invalid comparator: ' + comp);
this.operator = m[1];
+ if (this.operator === '=')
+ this.operator = '';
+
// if it literally is just '>' or '' then allow anything.
if (!m[2])
this.semver = ANY;
@@ -763,6 +770,11 @@ function replaceCaret(comp, loose) {
return comp.replace(r, function(_, M, m, p, pr) {
debug('caret', comp, _, M, m, p, pr);
var ret;
+ if (pr) {
+ if (pr.charAt(0) !== '-')
+ pr = '-' + pr;
+ } else
+ pr = '';
if (isX(M))
ret = '';
@@ -773,30 +785,14 @@ function replaceCaret(comp, loose) {
ret = '>=' + M + '.' + m + '.0-0 <' + M + '.' + (+m + 1) + '.0-0';
else
ret = '>=' + M + '.' + m + '.0-0 <' + (+M + 1) + '.0.0-0';
- } else if (pr) {
- debug('replaceCaret pr', pr);
- if (pr.charAt(0) !== '-')
- pr = '-' + pr;
- if (M === '0') {
- if (m === '0')
- ret = '=' + M + '.' + m + '.' + p + pr;
- else
- ret = '>=' + M + '.' + m + '.' + p + pr +
- ' <' + M + '.' + (+m + 1) + '.0-0';
- } else
- ret = '>=' + M + '.' + m + '.' + p + pr +
- ' <' + (+M + 1) + '.0.0-0';
- } else {
- if (M === '0') {
- if (m === '0')
- ret = '=' + M + '.' + m + '.' + p;
- else
- ret = '>=' + M + '.' + m + '.' + p + '-0' +
- ' <' + M + '.' + (+m + 1) + '.0-0';
- } else
- ret = '>=' + M + '.' + m + '.' + p + '-0' +
- ' <' + (+M + 1) + '.0.0-0';
- }
+ } else if (M === '0')
+ ret = '=' + M + '.' + m + '.' + p + pr;
+ else if (pr)
+ ret = '>=' + M + '.' + m + '.' + p + pr +
+ ' <' + (+M + 1) + '.0.0-0';
+ else
+ ret = '>=' + M + '.' + m + '.' + p + '-0' +
+ ' <' + (+M + 1) + '.0.0-0';
debug('caret return', ret);
return ret;