mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Generate a resource id everytime the gitUrl is set, fixes list command.
This commit is contained in:
@@ -109,7 +109,7 @@ var getNodes = function (packages, tree) {
|
||||
var version = packages[key].json.repository
|
||||
&& packages[key].json.repository.type == 'asset'
|
||||
&& packages[key]
|
||||
&& packages[key].version == "0.0.0" ?
|
||||
&& packages[key].version == '0.0.0' ?
|
||||
packages[key].json.repository.url : packages[key] && packages[key].version;
|
||||
|
||||
if (version && packages[key].tags.indexOf(version)) {
|
||||
@@ -118,11 +118,11 @@ var getNodes = function (packages, tree) {
|
||||
|
||||
if (Object.keys(tree[key]).length) {
|
||||
return {
|
||||
label: template('tree-branch', { package: key, version: version, upgrade: upgrade }, true),
|
||||
label: template('tree-branch', { 'package': key, version: version, upgrade: upgrade }, true),
|
||||
nodes: getNodes(packages, tree[key])
|
||||
};
|
||||
} else {
|
||||
return template('tree-branch', { package: key, version: version, upgrade: upgrade }, true);
|
||||
return template('tree-branch', { 'package': key, version: version, upgrade: upgrade }, true);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -87,6 +87,9 @@ var Package = function (name, endpoint, manager) {
|
||||
|
||||
// The id is an unique id that describes this package
|
||||
this.id = crypto.createHash('md5').update(this.name + '%' + this.tag + '%' + this.gitUrl + '%' + this.path + '%' + this.assetUrl).digest('hex');
|
||||
|
||||
// Generate a resource id
|
||||
if (this.gitUrl) this.generateResourceId();
|
||||
}
|
||||
|
||||
if (this.manager) {
|
||||
@@ -141,6 +144,7 @@ Package.prototype.lookup = function () {
|
||||
if (err) return this.emit('error', err);
|
||||
this.lookedUp = true;
|
||||
this.gitUrl = url;
|
||||
this.generateResourceId();
|
||||
this.emit('lookup');
|
||||
}.bind(this));
|
||||
};
|
||||
@@ -236,12 +240,17 @@ Package.prototype.loadJSON = function (name) {
|
||||
}.bind(this)).describeTag();
|
||||
}
|
||||
|
||||
// Only overwrite the name if not already set
|
||||
// This is because some packages have different names declared in the registry and the json
|
||||
if (!this.name) this.name = json.name;
|
||||
this.json = json;
|
||||
this.version = this.commit || json.commit || json.version;
|
||||
this.commit = this.commit || json.commit;
|
||||
// Only overwrite the name if not already set
|
||||
// This is because some packages have different names declared in the registry and the json
|
||||
if (!this.name) this.name = json.name;
|
||||
// Generate the resource id based on the gitUrl
|
||||
if (!this.gitUrl && json.repository && json.repository.type === 'git') {
|
||||
this.gitUrl = json.repository.url;
|
||||
this.generateResourceId();
|
||||
}
|
||||
|
||||
// TODO: bower could detect if the tag mismatches the json.version
|
||||
// this is very often to happen because developers tag their new releases but forget to update the json accordingly
|
||||
@@ -355,7 +364,6 @@ Package.prototype.exists = function (callback) {
|
||||
|
||||
Package.prototype.clone = function () {
|
||||
template('action', { name: 'cloning', shizzle: this.gitUrl }).on('data', this.emit.bind(this, 'data'));
|
||||
this.resourceId = crypto.createHash('md5').update(this.name + '%' + this.gitUrl).digest('hex');
|
||||
this.path = path.resolve(config.cache, this.name, this.resourceId);
|
||||
this.once('cache', function () {
|
||||
this.once('loadJSON', this.copy.bind(this)).checkout();
|
||||
@@ -519,7 +527,9 @@ Package.prototype.fetch = function () {
|
||||
|
||||
Package.prototype.fetchURL = function () {
|
||||
if (this.json.repository && this.json.repository.type == 'git') {
|
||||
this.emit('fetchURL', this.json.repository.url);
|
||||
this.gitUrl = this.json.repository.url;
|
||||
this.generateResourceId();
|
||||
this.emit('fetchURL', this.gitUrl);
|
||||
} else {
|
||||
this.emit('error', new Error('No git url found for ' + this.name));
|
||||
}
|
||||
@@ -557,6 +567,10 @@ Package.prototype.unserialize = function (obj) {
|
||||
this.version = this.tag;
|
||||
};
|
||||
|
||||
Package.prototype.generateResourceId = function () {
|
||||
this.resourceId = crypto.createHash('md5').update(this.name + '%' + this.gitUrl).digest('hex');
|
||||
};
|
||||
|
||||
Package.prototype.__defineGetter__('localPath', function () {
|
||||
return path.join(process.cwd(), config.directory, this.name);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user