Add more tests to the resolver factory.

This commit is contained in:
André Cruz
2013-05-02 23:45:49 +01:00
parent 4cc09e49ac
commit 409a8c2a77
3 changed files with 101 additions and 14 deletions

View File

@@ -29,7 +29,6 @@ var proxy = process.env.HTTPS_PROXY
var config;
try {
config = require('rc')('bower', {
json: 'bower.json',
directory: 'bower_components',
shorthandResolver: 'git://github.com/{{owner}}/{{package}}.git',
proxy: proxy,

View File

@@ -9,8 +9,9 @@ var UrlResolver = require('./resolvers/UrlResolver');
var config = require('../config');
var createError = require('../util/createError');
function createResolver(endpoint, options) {
function createResolver(endpoint, cfg) {
var split = endpoint.split('#'),
options = {},
source,
target;
@@ -22,10 +23,10 @@ function createResolver(endpoint, options) {
source = split[0];
target = split[1];
// Configure options
options = options || {};
options.target = options.target || target;
options.config = options.config || config;
// Setup options
cfg = cfg || config;
options.config = cfg;
options.target = target;
// Git case: git git+ssh, git+http, git+https
if (/^git(\+(ssh|https?))?:\/\//i.test(source)) {
@@ -33,7 +34,7 @@ function createResolver(endpoint, options) {
return Q.resolve(new GitRemoteResolver(source, options));
}
// Git case: .git at the end (probably ssh shortand)
// Git case: .git at the end (probably ssh shorthand)
if (/\.git$/i.test(source)) {
return Q.resolve(new GitRemoteResolver(source, options));
}
@@ -75,8 +76,8 @@ function createResolver(endpoint, options) {
throw err;
})
// If not, check against the registry
// TODO:
// TODO: if not, check against the registry
// note that the registry should also have a persistent cache for offline usage
// Finally throw a meaningful error
.fail(function () {
throw new createError('Could not find appropriate resolver for source "' + source + '"', 'ENORESOLVER');