mirror of
https://github.com/bower/bower.git
synced 2026-02-11 22:44:58 -05:00
Add more tests to the resolver factory.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user