diff --git a/index.js b/index.js index 5731078..b0ea7db 100644 --- a/index.js +++ b/index.js @@ -111,10 +111,13 @@ function remote(name, token) { */ function satisfy(refs, version){ + var master; for (var i = 0, ref; ref = refs[i++];) { + if ('master' == ref.name) master = ref; if (equal(ref.name, version)) return ref; } -}; + return master; +} /** * Arrange the refs diff --git a/test/gh-resolve.js b/test/gh-resolve.js index 9b3e24a..3bfa080 100644 --- a/test/gh-resolve.js +++ b/test/gh-resolve.js @@ -64,6 +64,14 @@ describe('resolve()', function(){ }); }) + it('should use master when there are no tags', function(done){ + resolve('mnmly/slider', function(err, ref){ + if (err) return done(err); + assert('master' == ref.name); + done(); + }) + }) + it('should provide better errors for invalid repos', function(done) { resolve('sweet/repo@amazing/version', function(err, ref){ assert(err);