mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Merge pull request #268 from twitter/package-json-name-is-authoritative
component.json package name should be authoritative
This commit is contained in:
@@ -367,9 +367,7 @@ Package.prototype.loadJSON = function () {
|
||||
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;
|
||||
this.name = json.name;
|
||||
|
||||
// Read the endpoint from the json to ensure it is set correctly
|
||||
this.readEndpoint();
|
||||
|
||||
@@ -311,6 +311,24 @@ describe('package', function () {
|
||||
pkg.loadJSON();
|
||||
});
|
||||
|
||||
it('Should correct guessed name with configured json file package-wise', function (next) {
|
||||
var pkg = new Package(null, __dirname + '/assets/package-jquery');
|
||||
|
||||
pkg.on('loadJSON', function () {
|
||||
assert(pkg.json);
|
||||
assert.equal(pkg.name, 'jquery');
|
||||
assert.equal(pkg.json.name, 'jquery');
|
||||
assert.equal(pkg.json.version, '1.8.1');
|
||||
next();
|
||||
});
|
||||
|
||||
pkg.on('error', function (err) {
|
||||
throw err;
|
||||
});
|
||||
|
||||
pkg.loadJSON();
|
||||
});
|
||||
|
||||
it('Should give an error on an invalid components.json', function (next) {
|
||||
var pkg = new Package('jquery', __dirname + '/assets/package-invalid-json');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user