mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Avoid having to deal with circular references when outputting json.
This commit is contained in:
@@ -104,8 +104,6 @@ Manager.prototype.install = function () {
|
||||
tag: 'install',
|
||||
data: name + (release ? '#' + release : ''),
|
||||
pkgMeta: decEndpoint.pkgMeta,
|
||||
origin: name,
|
||||
endpoint: decEndpoint
|
||||
});
|
||||
|
||||
// Remove existent and copy canonical package
|
||||
@@ -125,7 +123,9 @@ Manager.prototype.install = function () {
|
||||
return decEndpoint.pkgMeta;
|
||||
});
|
||||
})
|
||||
.then(deferred.resolve, deferred.reject, deferred.notify);
|
||||
.then(deferred.resolve, deferred.reject, function (notification) {
|
||||
return that._extendNotification(notification);
|
||||
});
|
||||
|
||||
// Unset working flag when done
|
||||
return deferred.promise
|
||||
@@ -199,15 +199,13 @@ Manager.prototype._fetch = function (decEndpoint) {
|
||||
.spread(this._onFetch.bind(this, deferred, decEndpoint))
|
||||
// If it fails, we make the whole process to error out
|
||||
.fail(function (err) {
|
||||
err.origin = that._getOrigin(decEndpoint);
|
||||
err.endpoint = decEndpoint;
|
||||
that._extendNotification(err, decEndpoint);
|
||||
deferred.reject(err);
|
||||
})
|
||||
// Listen to progress to proxy them to the resolve deferred
|
||||
// Note that we also mark where the notification is coming from
|
||||
.progress(function (notification) {
|
||||
notification.origin = that._getOrigin(decEndpoint);
|
||||
notification.endpoint = decEndpoint;
|
||||
that._extendNotification(notification, decEndpoint);
|
||||
deferred.notify(notification);
|
||||
});
|
||||
|
||||
@@ -389,8 +387,15 @@ Manager.prototype._dissect = function () {
|
||||
this._deferred.resolve(pkgMetas);
|
||||
};
|
||||
|
||||
Manager.prototype._getOrigin = function (decEndpoint) {
|
||||
return decEndpoint.name || decEndpoint.registryName || decEndpoint.resolverName;
|
||||
Manager.prototype._extendNotification = function (notification, decEndpoint) {
|
||||
notification.origin = decEndpoint.name || decEndpoint.registryName || decEndpoint.resolverName;
|
||||
notification.endpoint = {
|
||||
name: decEndpoint.name,
|
||||
source: decEndpoint.source,
|
||||
target: decEndpoint.target
|
||||
};
|
||||
|
||||
return notification;
|
||||
};
|
||||
|
||||
Manager.prototype._findHighestVersion = function (comparators) {
|
||||
|
||||
Reference in New Issue
Block a user