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.
This commit is contained in:
ekatek
2014-09-24 21:28:36 -07:00
parent 6feb5da948
commit 245059ef49
2 changed files with 2 additions and 20 deletions

View File

@@ -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) ||

View File

@@ -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);
};