component-require
Advanced tools
Comparing version 0.1.1 to 0.2.0
0.2.0 / 2013-01-01 | ||
================== | ||
* add support for absolute paths. | ||
0.1.1 / 2012-12-30 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -72,2 +72,3 @@ | ||
require.resolve = function(path) { | ||
if (path.charAt(0) === '/') path = path.slice(1); | ||
var index = path + '/index.js'; | ||
@@ -185,13 +186,14 @@ | ||
localRequire.resolve = function(path) { | ||
var c = path.charAt(0); | ||
if ('/' == c) return path.slice(1); | ||
if ('.' == c) return require.normalize(p, path); | ||
// resolve deps by returning | ||
// the dep in the nearest "deps" | ||
// directory | ||
if ('.' != path.charAt(0)) { | ||
var segs = parent.split('/'); | ||
var i = lastIndexOf(segs, 'deps') + 1; | ||
if (!i) i = 0; | ||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path; | ||
return path; | ||
} | ||
return require.normalize(p, path); | ||
var segs = parent.split('/'); | ||
var i = lastIndexOf(segs, 'deps') + 1; | ||
if (!i) i = 0; | ||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path; | ||
return path; | ||
}; | ||
@@ -198,0 +200,0 @@ |
{ | ||
"name": "component-require", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "require implementation for component(1)", | ||
@@ -5,0 +5,0 @@ "keywords": ["require", "component"], |
6243
170