Skip to content

Commit 6e0ded9

Browse files
committed
.repo -> .repository
1 parent 50b6e7f commit 6e0ded9

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

lib/remote.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
* you extend from it with Remote.extend().
66
*/
77

8-
var request = require('cogent')
9-
var semver = require('semver')
10-
var EventEmitter = require('events').EventEmitter
11-
var inherits = require('util').inherits
8+
var EventEmitter = require('events').EventEmitter;
9+
var validate = require('component-validator');
10+
var inherits = require('util').inherits;
11+
var request = require('cogent');
12+
var semver = require('semver');
1213

1314
module.exports = Remote
1415

@@ -141,12 +142,18 @@ Remote.prototype.json = function* (repo, ref) {
141142
cache[slug] = 'resolving';
142143
var json = yield* this._json(repo, ref);
143144
if (json) {
145+
// fix properties like .repo,
146+
// but not log anything because we're not npm.
147+
// there's nothing end users can do.
148+
validate(json, {
149+
verbose: false
150+
});
144151
var valid = semver.valid(ref);
145152
// overwrite the version in case it wasn't updated
146153
if (valid) json.version = valid;
147154
// add a repo property
148155
// to do: handle redirects
149-
if (!json.repo) json.repo = repo;
156+
if (!json.repository) json.repository = repo;
150157
} else {
151158
// i don't like `undefined`s
152159
json = null;

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"dependencies": {
2121
"debug": "*",
2222
"generator-supported": "~0.0.1",
23+
"component-validator": "*",
2324
"graceful-fs": "^2.0.2",
2425
"semver": "^2.2.1",
2526
"cogent": "~0.4.0",

test/github.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ describe('GitHub Remote', function () {
6060
json.name.should.equal('emitter')
6161
}))
6262

63-
it('should add the .repo property if missing', co(function* () {
63+
it('should add the .repository property if missing', co(function* () {
6464
var json = yield* remote.json('component/indexof', '0.0.2')
65-
json.repo.should.equal('component/indexof')
65+
json.repository.should.equal('component/indexof')
6666
}))
6767

6868
it('should resolve redirects', co(function* () {
6969
var json = yield* remote.json('jonathanong/clickable', '0.0.4')
7070
json.name.should.equal('clickable')
71-
json.repo.should.equal('component/clickable')
71+
json.repository.should.equal('component/clickable')
7272
}))
7373

7474
it('should cache results', co(function* () {

0 commit comments

Comments
 (0)