Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d15ae4

Browse filesBrowse files
committed
fix #20
1 parent 0ad93b0 commit 4d15ae4
Copy full SHA for 4d15ae4

File tree

Expand file treeCollapse file tree

4 files changed

+16
-21
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+16
-21
lines changed

‎lib/remote.js

Copy file name to clipboardExpand all lines: lib/remote.js
+11-8Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,10 @@ Remote.prototype.resolve = function* (remotes, repo, ref) {
8686
return;
8787
}
8888
// 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'];
9693
}
9794
var json = yield* this.json(repo, ref || availableVersions[0]);
9895
if (json) return this;
@@ -119,7 +116,13 @@ Remote.prototype.versions = function* (repo) {
119116
: cache[repo];
120117

121118
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+
}
123126
var versions = cache[repo] = references
124127
? references.filter(valid).sort(semver.rcompare)
125128
: null;

‎test/bitbucket.js

Copy file name to clipboardExpand all lines: test/bitbucket.js
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,8 @@ describe('BitBucket Remote', function () {
4242
}))
4343

4444
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;
5147
}))
5248
})
5349

‎test/github.js

Copy file name to clipboardExpand all lines: test/github.js
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,8 @@ describe('GitHub Remote', function () {
4545
}))
4646

4747
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;
5450
}))
5551
})
5652

‎test/remotes.js

Copy file name to clipboardExpand all lines: test/remotes.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('Remotes', function () {
8989
})
9090

9191
// 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 () {
9393
it('should return null', co(function* () {
9494
var r = yield* remote.resolve('kljalsdkfjlaksjdflkajsdf')
9595
assert.ok(!r)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.