|
@ -126,21 +126,15 @@ var module = (function () { |
|
|
var pathModule = createInternalModule('path', pathFn); |
|
|
var pathModule = createInternalModule('path', pathFn); |
|
|
var path = pathModule.exports; |
|
|
var path = pathModule.exports; |
|
|
|
|
|
|
|
|
// The paths that the user has specifically asked for. Highest priority.
|
|
|
var modulePaths = [path.join(process.execPath, "..", "..", "lib", "node")]; |
|
|
// This is what's hung on require.paths.
|
|
|
|
|
|
var modulePaths = []; |
|
|
if (process.env["HOME"]) { |
|
|
if (process.env.NODE_PATH) { |
|
|
modulePaths.unshift(path.join(process.env["HOME"], ".node_libraries")); |
|
|
modulePaths = process.env.NODE_PATH.split(":"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// The default global paths that are always checked.
|
|
|
if (process.env["NODE_PATH"]) { |
|
|
// Lowest priority.
|
|
|
modulePaths = process.env["NODE_PATH"].split(":").concat(modulePaths); |
|
|
var defaultPaths = []; |
|
|
|
|
|
if (process.env.HOME) { |
|
|
|
|
|
defaultPaths.push(path.join(process.env.HOME, ".node_modules")); |
|
|
|
|
|
defaultPaths.push(path.join(process.env.HOME, ".node_libraries")); |
|
|
|
|
|
} |
|
|
} |
|
|
defaultPaths.push(path.join(process.execPath, "..", "..", "lib", "node")); |
|
|
|
|
|
|
|
|
|
|
|
var extensions = {}; |
|
|
var extensions = {}; |
|
|
var registerExtension = removed('require.registerExtension() removed. Use require.extensions instead'); |
|
|
var registerExtension = removed('require.registerExtension() removed. Use require.extensions instead'); |
|
@ -171,7 +165,7 @@ var module = (function () { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function findModulePath (request, paths) { |
|
|
function findModulePath (request, paths) { |
|
|
var nextLoc = traverser(request, paths); |
|
|
var nextLoc = traverser(request, request.charAt(0) === '/' ? [''] : paths); |
|
|
|
|
|
|
|
|
var fs = requireNative('fs'); |
|
|
var fs = requireNative('fs'); |
|
|
|
|
|
|
|
@ -183,29 +177,15 @@ var module = (function () { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function modulePathWalk (parent) { |
|
|
|
|
|
if (parent._modulePaths) return parent._modulePaths; |
|
|
|
|
|
var p = parent.filename.split("/"); |
|
|
|
|
|
var mp = []; |
|
|
|
|
|
while (undefined !== p.pop()) { |
|
|
|
|
|
mp.push(p.join("/")+"/node_modules"); |
|
|
|
|
|
} |
|
|
|
|
|
return parent._modulePaths = mp; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// sync - no i/o performed
|
|
|
// sync - no i/o performed
|
|
|
function resolveModuleLookupPaths (request, parent) { |
|
|
function resolveModuleLookupPaths (request, parent) { |
|
|
|
|
|
|
|
|
if (natives[request]) return [request, []]; |
|
|
if (natives[request]) return [request, []]; |
|
|
|
|
|
|
|
|
if (request.charAt(0) === '/') { |
|
|
|
|
|
return [request, ['']]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var start = request.substring(0, 2); |
|
|
var start = request.substring(0, 2); |
|
|
if (start !== "./" && start !== "..") { |
|
|
if (start !== "./" && start !== "..") { |
|
|
var paths = modulePaths.concat(modulePathWalk(parent)).concat(defaultPaths); |
|
|
return [request, modulePaths]; |
|
|
return [request, paths]; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Is the parent an index module?
|
|
|
// Is the parent an index module?
|
|
|