Skip to content

Commit 3742571

Browse files
committed
Merge pull request bower#889 from bower/sync-up-dissected
Sync up dependencies and dependants after dissection, fixes bower#879.
2 parents 8e76d67 + 99cb553 commit 3742571

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

lib/core/Manager.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@ Manager.prototype.install = function () {
166166
return Q.all(promises);
167167
})
168168
.then(function () {
169+
// Sync up dissected dependencies and dependants
170+
// See: https://github.com/bower/bower/issues/879
171+
mout.object.forOwn(that._dissected, function (pkg) {
172+
// Sync dependencies
173+
mout.object.forOwn(pkg.dependencies, function (dependency, name) {
174+
var dissected = this._dissected[name];
175+
pkg.dependencies[name] = dissected || dependency;
176+
}, this);
177+
178+
// Sync dependants
179+
pkg.dependants = pkg.dependants.map(function (dependant) {
180+
return this._dissected[dependant.name] || dependant;
181+
}, this);
182+
}, that);
183+
169184
// Resolve with meaningful data
170185
return mout.object.map(that._dissected, function (decEndpoint) {
171186
return this.toData(decEndpoint);
@@ -448,7 +463,7 @@ Manager.prototype._dissect = function () {
448463
var semvers;
449464
var nonSemvers;
450465

451-
// Filter semver ones
466+
// Filter out non-semver ones
452467
semvers = decEndpoints.filter(function (decEndpoint) {
453468
return !!decEndpoint.pkgMeta.version;
454469
});
@@ -535,11 +550,6 @@ Manager.prototype._dissect = function () {
535550

536551
return true;
537552
}, this);
538-
539-
// Resolve with meaningful data
540-
return mout.object.map(this._dissected, function (decEndpoint) {
541-
return this.toData(decEndpoint);
542-
}, this);
543553
}.bind(this))
544554
.then(this._deferred.resolve, this._deferred.reject);
545555
};
@@ -566,8 +576,8 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
566576
}
567577

568578
picks.push.apply(picks, nonSemvers);
569-
// If there are only semver ones, figure out the which one
570-
// is compatible with every requirement
579+
// If there are only semver ones, figure out which one is
580+
// compatible with every requirement
571581
} else {
572582
suitable = mout.array.find(semvers, function (subject) {
573583
return semvers.every(function (decEndpoint) {
@@ -649,7 +659,7 @@ Manager.prototype._electSuitable = function (name, semvers, nonSemvers) {
649659
});
650660
}
651661

652-
// Exact match resolution
662+
// Exact match resolution (e.g. branches/tags)
653663
if (suitable === -1) {
654664
suitable = mout.array.findIndex(picks, function (pick) {
655665
return pick.target === resolution ||

0 commit comments

Comments
 (0)