Browse Source

Revert node_module lookup commits

Revert "Add ~/.node_modules as well as ~/.node_libraries"

This reverts commits
5e14c8bec0.
b0adaff67e.
492fc0d752.
v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
a375c6ae9a
  1. 36
      src/node.js

36
src/node.js

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

Loading…
Cancel
Save