@hapi/somever
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -35,6 +35,6 @@ 'use strict'; | ||
exports.match = function (version, range) { | ||
exports.match = function (version, range, options) { | ||
try { | ||
return exports.range(range).match(version); | ||
return exports.range(range).match(version, options); | ||
} | ||
@@ -58,3 +58,3 @@ catch (err) { | ||
if (options.range && | ||
if (options.range && !options.includePrerelease && | ||
a.prerelease.length && | ||
@@ -85,11 +85,13 @@ (a.major !== b.major || a.minor !== b.minor || a.patch !== b.patch || !b.prerelease.length)) { | ||
if (!a.prerelease.length && | ||
!b.prerelease.length) { | ||
// With includePrerelease patch wildcard encompasses prereleases, otherwise prerelease < none | ||
if (!a.prerelease.length && !b.prerelease.length) { | ||
return 0; | ||
} | ||
if (!!a.prerelease.length !== !!b.prerelease.length) { | ||
return (a.prerelease.length ? aFirst : bFirst); // prerelease < none | ||
else if (!b.prerelease.length) { | ||
return options.includePrerelease && b.patch === internals.any ? 0 : aFirst; | ||
} | ||
else if (!a.prerelease.length) { | ||
return options.includePrerelease && a.patch === internals.any ? 0 : bFirst; | ||
} | ||
@@ -336,6 +338,6 @@ for (let i = 0; ; ++i) { | ||
if (version.minor === internals.any) { | ||
this._rule('<', { major: version.major + 1, minor: 0, patch: 0 }); | ||
this._rule('<', { major: version.major + 1, minor: 0, patch: 0, prerelease: [0] }); | ||
} | ||
else { | ||
this._rule('<', { major: version.major, minor: version.minor + 1, patch: 0 }); | ||
this._rule('<', { major: version.major, minor: version.minor + 1, patch: 0, prerelease: [0] }); | ||
} | ||
@@ -365,10 +367,10 @@ | ||
if (version.minor === 0) { | ||
this._rule('<', { major: 0, minor: 0, patch: version.patch + 1 }); | ||
this._rule('<', { major: 0, minor: 0, patch: version.patch + 1, prerelease: [0] }); | ||
} | ||
else { | ||
this._rule('<', { major: 0, minor: version.minor + 1, patch: 0 }); | ||
this._rule('<', { major: 0, minor: version.minor + 1, patch: 0, prerelease: [0] }); | ||
} | ||
} | ||
else { | ||
this._rule('<', { major: version.major + 1, minor: 0, patch: 0 }); | ||
this._rule('<', { major: version.major + 1, minor: 0, patch: 0, prerelease: [0] }); | ||
} | ||
@@ -459,3 +461,3 @@ | ||
match(version) { | ||
match(version, options = {}) { | ||
@@ -465,3 +467,3 @@ version = exports.version(version, this._settings); // Always parse to validate | ||
if (this._anything) { | ||
return !version.prerelease.length; | ||
return !!options.includePrerelease || !version.prerelease.length; | ||
} | ||
@@ -478,3 +480,3 @@ | ||
for (const rule of rules) { | ||
const compare = version.compare(rule.version, Object.assign(this._settings, { range: true })); | ||
const compare = version.compare(rule.version, Object.assign(this._settings, options, { range: true })); | ||
const exclude = Math.abs(compare) === 2; | ||
@@ -481,0 +483,0 @@ |
{ | ||
"name": "@hapi/somever", | ||
"description": "Semantic versioning rules parser", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"repository": "git://github.com/hapijs/somever", | ||
@@ -27,3 +27,3 @@ "main": "lib/index.js", | ||
"@hapi/eslint-plugin": "*", | ||
"@hapi/lab": "25.0.0-beta.1" | ||
"@hapi/lab": "^25.0.1" | ||
}, | ||
@@ -30,0 +30,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17031
382