Skip to content

Commit

Permalink
Merge pull request #18 from stephenmathieson/add/username-password-su…
Browse files Browse the repository at this point in the history
…pport

Add/username password support
  • Loading branch information
matthewmueller committed Nov 7, 2014
2 parents 1e85a89 + 287868a commit 3d5aa04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

test:
test: node_modules
@node_modules/.bin/mocha \
--reporter spec \
--timeout 8s

node_modules: package.json
@npm install
@touch $@

.PHONY: test
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ function resolve(slug, opts, fn){
fn = opts
opts = {};
}

var token = opts.token || (
opts.password && opts.username
? [opts.username, opts.password].join(':')
: ''
);
var repo = slug.split('@')[0];
var ref = slug.split('@')[1];
var url = remote(repo, opts.token);
var url = remote(repo, token);
var cmd = fmt('git ls-remote --tags --heads %s', url);

// options
Expand Down
10 changes: 10 additions & 0 deletions test/gh-resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ describe('resolve()', function(){
});
})

it('should mask password on error', function(done) {
var opts = { username: 'someuser', password: 'somepassword' };
resolve('decent/repo@good/version', opts, function(err){
assert(err);
assert(!~err.message.indexOf('somepassword'));
assert(~err.message.indexOf('someuser:<token>@github'));
done();
})
})

it('should work on weird semvers', function(done){
resolve('chjj/marked@*', function(err, ref){
if (err) return done(err);
Expand Down

0 comments on commit 3d5aa04

Please sign in to comment.