diff options
Diffstat (limited to 'deps/npm/node_modules/semver/semver.js')
-rw-r--r-- | deps/npm/node_modules/semver/semver.js | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/deps/npm/node_modules/semver/semver.js b/deps/npm/node_modules/semver/semver.js index 9e9470d86f..a7385b41c5 100644 --- a/deps/npm/node_modules/semver/semver.js +++ b/deps/npm/node_modules/semver/semver.js @@ -258,6 +258,8 @@ function SemVer(version, loose) { return version; else version = version.version; + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version); } if (!(this instanceof SemVer)) @@ -330,7 +332,7 @@ SemVer.prototype.comparePre = function(other) { return -1; else if (!this.prerelease.length && other.prerelease.length) return 1; - else if (!this.prerelease.lenth && !other.prerelease.length) + else if (!this.prerelease.length && !other.prerelease.length) return 0; var i = 0; @@ -351,19 +353,49 @@ SemVer.prototype.comparePre = function(other) { } while (++i); }; +// 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) { switch (release) { + case 'premajor': + this.inc('major'); + this.inc('pre'); + break; + case 'preminor': + this.inc('minor'); + this.inc('pre'); + break; + case 'prepatch': + this.inc('patch'); + this.inc('pre'); + 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'); + break; case 'major': this.major++; this.minor = -1; case 'minor': this.minor++; - this.patch = -1; + this.patch = 0; + this.prerelease = []; + break; case 'patch': - this.patch++; + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) + this.patch++; this.prerelease = []; break; - case 'prerelease': + // This probably shouldn't be used publically. + // 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]; else { |