diff --git a/lib/commands/register.js b/lib/commands/register.js index 9c096a3b7..da9d0d2c4 100644 --- a/lib/commands/register.js +++ b/lib/commands/register.js @@ -4,16 +4,23 @@ var PackageRepository = require('../core/PackageRepository'); var createError = require('../util/createError'); var defaultConfig = require('../config'); -function register(logger, name, url, config) { +function register(logger, name, source, config) { var repository; var registryClient; var force; + var url; + var githubSourceRegex = /^\w[\w-]+\/\w[\w-]+$/; + var getGithubUrl = function(source) { + return 'git@github.com:' + source + '.git'; + }; config = defaultConfig(config); force = config.force; name = (name || '').trim(); - url = (url || '').trim(); + source = (source || '').trim(); + + url = source.match(githubSourceRegex) ? getGithubUrl(source) : source; // Bypass any cache config.offline = false; diff --git a/test/commands/register.js b/test/commands/register.js index c677ed95d..3d3b2d3f8 100644 --- a/test/commands/register.js +++ b/test/commands/register.js @@ -86,6 +86,19 @@ describe('bower register', function () { }); }); + it('should call registry client with name and github source', function () { + mainPackage.prepare(); + + var register = registerFactory(mainPackage.path, mainPackage.meta()); + return helpers.run(register, ['some-name', 'some-repo/package']) + .spread(function (result) { + expect(result).to.eql({ + // Result from register action on stub + name: 'some-name', url: 'git@github.com:some-repo/package.git' + }); + }); + }); + it('should confirm in interactive mode', function () { mainPackage.prepare();