Skip to content

Commit

Permalink
Add support for registering package with github's orgname/reponame (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
rpunkfu authored and sheerun committed Apr 12, 2016
1 parent 7c54812 commit 8ee2d78
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/commands/register.js
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions test/commands/register.js
Expand Up @@ -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();

Expand Down

0 comments on commit 8ee2d78

Please sign in to comment.