Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for registering package with github's orgname/reponame #2248

Merged
merged 1 commit into from Apr 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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