From 245059ef49ba069709378dca20a1b71daaec7e01 Mon Sep 17 00:00:00 2001 From: ekatek Date: Wed, 24 Sep 2014 21:28:36 -0700 Subject: [PATCH] if we are asking for a prerelease, we should run the same comparison as normal Previously, if we were asking for a pre-release, we would only return true if it was the same pre-release, or at least on the same release. But that's not true. 1.2.4 should be valid if we want 1.2.4-rc0, for example, and, even 1.2.3-rc0. (I mean, if it has the same ecv, which it might not). This is also what was causing some of the issues around 0.9.1 rollout, we think. So, we are going to try treating rcs like normal versions as far as comparisons go. We still don't want to give you an rc unless you asked for it though. --- packages/constraint-solver/resolver.js | 10 ++-------- tools/package-version-parser.js | 12 ------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/packages/constraint-solver/resolver.js b/packages/constraint-solver/resolver.js index 9166c4be01..d7fa36b3ab 100644 --- a/packages/constraint-solver/resolver.js +++ b/packages/constraint-solver/resolver.js @@ -418,17 +418,11 @@ ConstraintSolver.Constraint.prototype.isSatisfied = function ( throw Error("Unknown constraint type: " + currConstraint.type); } - // If you are asking for a pre-release, you need to get a - // pre-release on the same release that has higher precendence. - if (/-/.test(currConstraint.version)) { - return PackageVersion.prereleaseLessThan( - currConstraint.version, candidateUV.version); - } - // If you're not asking for a pre-release (and you are not in pre-releases-OK // mode), you'll only get it if it was a top level explicit mention (eg, in // the release). - if (/-/.test(candidateUV.version) && !resolveContext.useRCsOK) { + if (!/-/.test(currConstraint.version) && + /-/.test(candidateUV.version) && !resolveContext.useRCsOK) { if (currConstraint.version === candidateUV.version) return true; if (!_.has(resolveContext.topLevelPrereleases, self.name) || diff --git a/tools/package-version-parser.js b/tools/package-version-parser.js index 2c4588cb74..0374c4d9a8 100644 --- a/tools/package-version-parser.js +++ b/tools/package-version-parser.js @@ -337,15 +337,3 @@ PV.invalidFirstFormatConstraint = function (validConstraint) { return (/_/.test(validConstraint) || /\|/.test(validConstraint)); }; - -// Returns true if both v1 and v2 represent pre-releases off of the -// same base release, and v2 >= v1 -PV.prereleaseLessThan = function (v1, v2) { - if (!/-/.test(v1) || !/-/.test(v2)) - return false; - - if (v1.split('-')[0] !== v2.split('-')[0]) - return false; - - return PV.lessThan(v1, v2); -};