Comparing version 0.2.2 to 0.2.3
@@ -60,2 +60,3 @@ /* | ||
this._now = Date.now(); | ||
this.aliases = {}; | ||
this.options = $.extend(true, {}, exports.options); | ||
@@ -86,3 +87,3 @@ | ||
if (o.detect) { | ||
paths = deps.find(o.detect, o.paths); | ||
paths = deps.find(o.detect, o.paths, this.aliases); | ||
} else { | ||
@@ -103,2 +104,20 @@ paths = utils.findSync(o.root || this.root, o.pattern, o.rec); | ||
/** | ||
* Set aliases. | ||
* F.e. if you want to require('jquery'), but the path is jquery/jquery | ||
* | ||
* @param {String|Object} src src path or aliases map | ||
* @param {String} [target] target path | ||
* @return {Build} this | ||
*/ | ||
proto.alias = function(src, target) { | ||
if (src && target) { | ||
this.aliases[src] = target; | ||
} else if (typeof src == 'object') { | ||
$.extend(this.aliases, src); | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Add one file from given path, optionally define the target dir | ||
@@ -105,0 +124,0 @@ * @param {string|Array} path to file. |
@@ -34,5 +34,6 @@ /* | ||
* @param {Array} [paths] array of lookup paths like require.paths. | ||
* @param {Object} [aliases] | ||
* @return {Array} deps paths. | ||
*/ | ||
exports.find = function(opts, paths) { | ||
exports.find = function(opts, paths, aliases) { | ||
var map = {}, | ||
@@ -62,2 +63,6 @@ path = opts.path || opts, | ||
for (id in deps) { | ||
if (aliases && aliases[id]) { | ||
id = aliases[id]; | ||
} | ||
// css and html files can be also included | ||
@@ -64,0 +69,0 @@ if (!/\.js|\.css|\.html$/.test(id)) { |
@@ -197,2 +197,9 @@ var n = require('natives'), | ||
} catch(e) { | ||
// add 'index.js' file and try again | ||
if (!n.path.extname(path)) { | ||
try { | ||
return exports.resolvePath(n.path.join(path,'index.js'), hostFilePath, root, lookup); | ||
} catch(e) {} | ||
} | ||
// add '.js' extention and try again | ||
@@ -199,0 +206,0 @@ if (!/\.js$/.test(path)) { |
{ | ||
"name": "ams", | ||
"description": "ams - asset management system - plugin enabled build tool with jquery like API", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"author": "Oleg Slobodskoi <oleg008@gmail.com>", | ||
@@ -6,0 +6,0 @@ "repository": "git://github.com/kof/node-ams.git", |
263754
3538