mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Fix some more errors with duplicate callbacks being called, #274.
This commit is contained in:
@@ -132,8 +132,12 @@ Manager.prototype.resolveEndpoints = function () {
|
||||
this.dependencies[name] = this.dependencies[name] || [];
|
||||
this.dependencies[name].push(pkg);
|
||||
|
||||
pkg.once('resolve', next).resolve();
|
||||
this.gatherPackageErrors(pkg, next);
|
||||
this.gatherPackageErrors(pkg);
|
||||
pkg.once('error', next);
|
||||
pkg.once('resolve', function () {
|
||||
pkg.removeListener('error', next);
|
||||
next();
|
||||
}).resolve();
|
||||
}.bind(this), this.emit.bind(this, 'resolveEndpoints'));
|
||||
|
||||
return this;
|
||||
@@ -156,8 +160,12 @@ Manager.prototype.resolveFromJson = function () {
|
||||
this.dependencies[name] = this.dependencies[name] || [];
|
||||
this.dependencies[name].push(pkg);
|
||||
|
||||
pkg.once('resolve', next).resolve();
|
||||
this.gatherPackageErrors(pkg, next);
|
||||
this.gatherPackageErrors(pkg);
|
||||
pkg.once('error', next);
|
||||
pkg.once('resolve', function () {
|
||||
pkg.removeListener('error', next);
|
||||
next();
|
||||
}).resolve();
|
||||
}.bind(this), this.emit.bind(this, 'resolveFromJson'));
|
||||
}.bind(this)).loadJSON();
|
||||
|
||||
@@ -212,9 +220,7 @@ Manager.prototype.prune = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
Manager.prototype.gatherPackageErrors = function (pkg, next) {
|
||||
var calledNext = false;
|
||||
|
||||
Manager.prototype.gatherPackageErrors = function (pkg) {
|
||||
// Listen to all the errors
|
||||
// The first error will call the next callback and we continue to gather more until the end
|
||||
// This makes sense because a package forwards its deep dependencies errors
|
||||
@@ -227,10 +233,6 @@ Manager.prototype.gatherPackageErrors = function (pkg, next) {
|
||||
}
|
||||
|
||||
this.errors.push({ pkg: pkg, error: err });
|
||||
if (next && !calledNext) {
|
||||
calledNext = true;
|
||||
next();
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user