mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
Not every notification was being extended properly.
Standardise variables.
This commit is contained in:
@@ -109,6 +109,7 @@ Manager.prototype.install = function () {
|
||||
id: 'install',
|
||||
message: name + (release ? '#' + release : ''),
|
||||
data: {
|
||||
canonicalPkg: decEndpoint.canonicalPkg,
|
||||
pkgMeta: decEndpoint.pkgMeta
|
||||
}
|
||||
}, decEndpoint));
|
||||
@@ -116,7 +117,7 @@ Manager.prototype.install = function () {
|
||||
// Remove existent and copy canonical package
|
||||
dest = path.join(destDir, name);
|
||||
promise = Q.nfcall(rimraf, dest)
|
||||
.then(copy.copyDir.bind(copy, decEndpoint.dir, dest))
|
||||
.then(copy.copyDir.bind(copy, decEndpoint.canonicalPkg, dest))
|
||||
.fail(function (err) {
|
||||
throw that._extendNotification(err, decEndpoint);
|
||||
});
|
||||
@@ -238,7 +239,7 @@ Manager.prototype._onFetch = function (deferred, decEndpoint, canonicalPkg, pkgM
|
||||
|
||||
// Store some needed stuff
|
||||
decEndpoint.name = name = decEndpoint.name || pkgMeta.name;
|
||||
decEndpoint.dir = canonicalPkg;
|
||||
decEndpoint.canonicalPkg = canonicalPkg;
|
||||
decEndpoint.pkgMeta = pkgMeta;
|
||||
|
||||
// Add to the resolved list, marking it as resolved
|
||||
@@ -286,7 +287,7 @@ Manager.prototype._parseDependencies = function (decEndpoint, pkgMeta) {
|
||||
|
||||
// Simply mark it as resolved
|
||||
if (compatible) {
|
||||
childDecEndpoint.dir = compatible.dir;
|
||||
childDecEndpoint.canonicalPkg = compatible.canonicalPkg;
|
||||
childDecEndpoint.pkgMeta = compatible.pkgMeta;
|
||||
this._resolved[key].push(childDecEndpoint);
|
||||
return;
|
||||
@@ -304,7 +305,7 @@ Manager.prototype._parseDependencies = function (decEndpoint, pkgMeta) {
|
||||
// Wait for it to resolve and then add it to the resolved packages
|
||||
if (compatible) {
|
||||
childDecEndpoint = compatible.promise.then(function () {
|
||||
childDecEndpoint.dir = compatible.dir;
|
||||
childDecEndpoint.canonicalPkg = compatible.canonicalPkg;
|
||||
childDecEndpoint.pkgMeta = compatible.pkgMeta;
|
||||
this._resolved[key].push(childDecEndpoint);
|
||||
}.bind(this));
|
||||
|
||||
@@ -23,9 +23,7 @@ function PackageRepository(config) {
|
||||
// -----------------
|
||||
|
||||
PackageRepository.prototype.fetch = function (decEndpoint) {
|
||||
var resolver;
|
||||
var pkgMeta;
|
||||
var canonicalPkg;
|
||||
var info = {};
|
||||
var deferred = Q.defer();
|
||||
var that = this;
|
||||
|
||||
@@ -33,8 +31,8 @@ PackageRepository.prototype.fetch = function (decEndpoint) {
|
||||
resolverFactory(decEndpoint, this._registryClient, this._config)
|
||||
// Decide if we retrieve from the cache or not
|
||||
// Also decide we if validate the cached entry or not
|
||||
.then(function (res) {
|
||||
resolver = res;
|
||||
.then(function (resolver) {
|
||||
info.resolver = resolver;
|
||||
|
||||
// If force flag is used, bypass cache
|
||||
if (that._config.force) {
|
||||
@@ -50,9 +48,9 @@ PackageRepository.prototype.fetch = function (decEndpoint) {
|
||||
// cache because transformations/normalisations can occur
|
||||
return that._resolveCache.retrieve(resolver.getSource(), resolver.getTarget())
|
||||
// Decide if we can use the one from the resolve cache
|
||||
.spread(function (canonical, meta) {
|
||||
.spread(function (canonicalPkg, pkgMeta) {
|
||||
// If there's no package in the cache
|
||||
if (!canonical) {
|
||||
if (!canonicalPkg) {
|
||||
// And the offline flag is passed, error out
|
||||
if (that._config.offline) {
|
||||
throw createError('No cached version for ' + resolver.getSource() + '#' + resolver.getTarget(), 'ENOCACHE', {
|
||||
@@ -70,8 +68,8 @@ PackageRepository.prototype.fetch = function (decEndpoint) {
|
||||
return that._resolve(resolver);
|
||||
}
|
||||
|
||||
canonicalPkg = canonical;
|
||||
pkgMeta = meta;
|
||||
info.canonicalPkg = canonicalPkg;
|
||||
info.pkgMeta = pkgMeta;
|
||||
|
||||
deferred.notify({
|
||||
level: 'info',
|
||||
@@ -113,27 +111,13 @@ PackageRepository.prototype.fetch = function (decEndpoint) {
|
||||
});
|
||||
});
|
||||
})
|
||||
.then(deferred.resolve, deferred.reject, function (notification) {
|
||||
// Store the resolver info in each notification
|
||||
if (resolver) {
|
||||
notification.resolver = {
|
||||
name: resolver.getName(),
|
||||
source: resolver.getSource(),
|
||||
target: resolver.getTarget()
|
||||
};
|
||||
}
|
||||
.then(deferred.resolve, deferred.reject, deferred.notify);
|
||||
|
||||
// Store the canonical package and it's meta in each notification
|
||||
if (canonicalPkg) {
|
||||
notification.data = notification.data || {};
|
||||
notification.data.canonicalPkg = canonicalPkg;
|
||||
notification.data.pkgMeta = pkgMeta;
|
||||
}
|
||||
|
||||
deferred.notify(notification);
|
||||
return deferred.promise
|
||||
.progress(function (notification) {
|
||||
// Extend each notification with meaningful data
|
||||
return that._extendNotification(notification, info);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
PackageRepository.prototype.empty = function (name) {
|
||||
@@ -171,4 +155,25 @@ PackageRepository.prototype._resolve = function (resolver) {
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
PackageRepository.prototype._extendNotification = function (notification, info) {
|
||||
notification.data = notification.data || {};
|
||||
|
||||
// Store the resolver info in each notification
|
||||
if (info.resolver) {
|
||||
notification.data.resolver = {
|
||||
name: info.resolver.getName(),
|
||||
source: info.resolver.getSource(),
|
||||
target: info.resolver.getTarget()
|
||||
};
|
||||
}
|
||||
|
||||
// Store the canonical package and it's meta in each notification
|
||||
if (info.canonicalPkg) {
|
||||
notification.data.canonicalPkg = info.canonicalPkg;
|
||||
notification.data.pkgMeta = info.pkgMeta;
|
||||
}
|
||||
|
||||
return notification;
|
||||
};
|
||||
|
||||
module.exports = PackageRepository;
|
||||
|
||||
Reference in New Issue
Block a user