diff --git a/packages/constraint-solver/constraint-solver.js b/packages/constraint-solver/constraint-solver.js index 065c9ca3a4..19f9f97010 100644 --- a/packages/constraint-solver/constraint-solver.js +++ b/packages/constraint-solver/constraint-solver.js @@ -195,10 +195,13 @@ ConstraintSolver.PackagesResolver.prototype.resolve = function ( // split every package name to one or more archs belonging to that package // (["foobar"] => ["foobar#os", "foobar#web.browser", ...]) // XXX for now just hardcode in all of the known architectures - options.upgrade = _.filter(_.flatten(_.map(options.upgrade, function (packageName) { - return [packageName + "#os", packageName + "#web.browser", - packageName + "#web.cordova"]; - })), _.identity); + var upgradeUnibuilds = {}; + _.each(options.upgrade, function (packageName) { + _.each(self._unibuildsForPackage(packageName), function (unibuildName) { + upgradeUnibuilds[unibuildName] = true; + }); + }); + options.upgrade = upgradeUnibuilds; var dc = self._splitDepsToConstraints(dependencies, constraints); @@ -207,15 +210,18 @@ ConstraintSolver.PackagesResolver.prototype.resolve = function ( var res = null; // If a previous solution existed, try resolving with additional (weak) - // equality constraints on all the versions from the previous solution. If - // it's possible to solve the constraints without changing any of the previous - // versions (though we may add more choices in addition, or remove some - // now-unnecessary choices) then that's our first try. + // equality constraints on all the versions from the previous solution (except + // those we've explicitly been asked to update). If it's possible to solve the + // constraints without changing any of the previous versions (though we may + // add more choices in addition, or remove some now-unnecessary choices) then + // that's our first try. if (!_.isEmpty(options.previousSolution)) { var constraintsWithPreviousSolutionLock = _.clone(dc.constraints); _.each(options.previousSolution, function (uv) { - constraintsWithPreviousSolutionLock.push( - self.resolver.getConstraint(uv.name, '=' + uv.version)); + if (!_.has(options.upgrade, uv.name)) { + constraintsWithPreviousSolutionLock.push( + self.resolver.getConstraint(uv.name, '=' + uv.version)); + } }); try { // Try running the resolver. If it fails to resolve, that's OK, we'll keep @@ -337,7 +343,7 @@ ConstraintSolver.PackagesResolver.prototype._getResolverOptions = // if the upgrade is preferred over preserving previous solution, pretend // there are no previous solution _.each(prevSol, function (uv) { - if (! _.contains(options.upgrade, uv.name)) + if (! _.has(options.upgrade, uv.name)) prevSolMapping[uv.name] = uv; });