File tree 3 files changed +16
-8
lines changed
3 files changed +16
-8
lines changed Original file line number Diff line number Diff line change 5
5
* you extend from it with Remote.extend().
6
6
*/
7
7
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' ) ;
12
13
13
14
module . exports = Remote
14
15
@@ -141,12 +142,18 @@ Remote.prototype.json = function* (repo, ref) {
141
142
cache [ slug ] = 'resolving' ;
142
143
var json = yield * this . _json ( repo , ref ) ;
143
144
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
+ } ) ;
144
151
var valid = semver . valid ( ref ) ;
145
152
// overwrite the version in case it wasn't updated
146
153
if ( valid ) json . version = valid ;
147
154
// add a repo property
148
155
// to do: handle redirects
149
- if ( ! json . repo ) json . repo = repo ;
156
+ if ( ! json . repository ) json . repository = repo ;
150
157
} else {
151
158
// i don't like `undefined`s
152
159
json = null ;
Original file line number Diff line number Diff line change 20
20
"dependencies" : {
21
21
"debug" : " *" ,
22
22
"generator-supported" : " ~0.0.1" ,
23
+ "component-validator" : " *" ,
23
24
"graceful-fs" : " ^2.0.2" ,
24
25
"semver" : " ^2.2.1" ,
25
26
"cogent" : " ~0.4.0" ,
Original file line number Diff line number Diff line change @@ -60,15 +60,15 @@ describe('GitHub Remote', function () {
60
60
json . name . should . equal ( 'emitter' )
61
61
} ) )
62
62
63
- it ( 'should add the .repo property if missing' , co ( function * ( ) {
63
+ it ( 'should add the .repository property if missing' , co ( function * ( ) {
64
64
var json = yield * remote . json ( 'component/indexof' , '0.0.2' )
65
- json . repo . should . equal ( 'component/indexof' )
65
+ json . repository . should . equal ( 'component/indexof' )
66
66
} ) )
67
67
68
68
it ( 'should resolve redirects' , co ( function * ( ) {
69
69
var json = yield * remote . json ( 'jonathanong/clickable' , '0.0.4' )
70
70
json . name . should . equal ( 'clickable' )
71
- json . repo . should . equal ( 'component/clickable' )
71
+ json . repository . should . equal ( 'component/clickable' )
72
72
} ) )
73
73
74
74
it ( 'should cache results' , co ( function * ( ) {
You can’t perform that action at this time.
0 commit comments