File tree Expand file tree Collapse file tree 4 files changed +16
-21
lines changed
Filter options
Expand file tree Collapse file tree 4 files changed +16
-21
lines changed
Original file line number Diff line number Diff line change @@ -86,13 +86,10 @@ Remote.prototype.resolve = function* (remotes, repo, ref) {
86
86
return ;
87
87
}
88
88
// use latest tag, and if it's not available, then master
89
- var availableVersions = [ ] ;
90
- try {
91
- availableVersions = yield * this . versions ( repo ) ;
92
- } catch ( err ) { // no tags available, then try master branch
93
- }
94
- if ( availableVersions . length === 0 ) {
95
- availableVersions . push ( 'master' ) ;
89
+ var availableVersions = yield * this . versions ( repo ) ;
90
+
91
+ if ( availableVersions == null ) {
92
+ availableVersions = [ 'master' ] ;
96
93
}
97
94
var json = yield * this . json ( repo , ref || availableVersions [ 0 ] ) ;
98
95
if ( json ) return this ;
@@ -119,7 +116,13 @@ Remote.prototype.versions = function* (repo) {
119
116
: cache [ repo ] ;
120
117
121
118
cache [ repo ] = 'resolving' ;
122
- var references = yield * this . _versions ( repo ) ;
119
+ var references ;
120
+ try {
121
+ references = yield * this . _versions ( repo ) ;
122
+ } catch ( err ) {
123
+ // catch 404 and non 200 status codes
124
+ // references = undefined
125
+ }
123
126
var versions = cache [ repo ] = references
124
127
? references . filter ( valid ) . sort ( semver . rcompare )
125
128
: null ;
Original file line number Diff line number Diff line change @@ -42,12 +42,8 @@ describe('BitBucket Remote', function () {
42
42
} ) )
43
43
44
44
it ( 'should throw if the repository doesn\'t exist' , co ( function * ( ) {
45
- try {
46
- yield * remote . versions ( 'netpoetica/component-easterbunny' ) ;
47
- throw new Error ( ) ;
48
- } catch ( err ) {
49
- err . message . should . include ( 'check that this repository still exists' ) ;
50
- }
45
+ var res = yield * remote . versions ( 'netpoetica/component-easterbunny' ) ;
46
+ ( res == null ) . should . true ;
51
47
} ) )
52
48
} )
53
49
Original file line number Diff line number Diff line change @@ -45,12 +45,8 @@ describe('GitHub Remote', function () {
45
45
} ) )
46
46
47
47
it ( 'throw if the repository doesn\'t exist' , co ( function * ( ) {
48
- try {
49
- yield * remote . versions ( 'jonathanong/alisudhlsdiuh' ) ;
50
- throw new Error ( ) ;
51
- } catch ( err ) {
52
- err . message . should . include ( 'check that this repository still exists' ) ;
53
- }
48
+ var res = yield * remote . versions ( 'jonathanong/alisudhlsdiuh' ) ;
49
+ ( res == null ) . should . true ;
54
50
} ) )
55
51
} )
56
52
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ describe('Remotes', function () {
89
89
} )
90
90
91
91
// this test fails in combination with the other tests, .only works!
92
- describe . skip ( 'FIXME: when no remote matches', function ( ) {
92
+ describe ( ' when no remote matches', function ( ) {
93
93
it ( 'should return null' , co ( function * ( ) {
94
94
var r = yield * remote . resolve ( 'kljalsdkfjlaksjdflkajsdf' )
95
95
assert . ok ( ! r )
You can’t perform that action at this time.
0 commit comments