diff --git a/lib/repl.js b/lib/repl.js index 83f52e81286..5b59d0ac954 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -247,12 +247,7 @@ REPLServer.prototype.complete = function(line) { var dir, files, f, name, base, ext, abs, subfiles, s; group = []; for (i = 0; i < require.paths.length; i++) { - dir = require.paths[i]; - if (subdir && subdir[0] === '/') { - dir = subdir; - } else if (subdir) { - dir = path.join(dir, subdir); - } + dir = path.resolve(require.paths[i], subdir); try { files = fs.readdirSync(dir); } catch (e) { @@ -271,7 +266,7 @@ REPLServer.prototype.complete = function(line) { group.push(subdir + base); } } else { - abs = path.join(dir, name); + abs = path.resolve(dir, name); try { if (fs.statSync(abs).isDirectory()) { group.push(subdir + name + '/'); diff --git a/src/node.js b/src/node.js index f6cc2392ced..13816642fe2 100644 --- a/src/node.js +++ b/src/node.js @@ -132,11 +132,11 @@ var path = requireNative('path'); - var modulePaths = [path.join(process.execPath, '..', '..', 'lib', 'node')]; + var modulePaths = [path.resolve(process.execPath, '..', '..', 'lib', 'node')]; if (process.env['HOME']) { - modulePaths.unshift(path.join(process.env['HOME'], '.node_libraries')); - modulePaths.unshift(path.join(process.env['HOME'], '.node_modules')); + modulePaths.unshift(path.resolve(process.env['HOME'], '.node_libraries')); + modulePaths.unshift(path.resolve(process.env['HOME'], '.node_modules')); } if (process.env['NODE_PATH']) { @@ -188,11 +188,11 @@ for (var i = 0, PL = paths.length; i < PL; i++) { var p = paths[i], // try to join the request to the path - f = tryFile(path.join(p, request)) || + f = tryFile(path.resolve(p, request)) || // try it with each of the extensions - tryExtensions(path.join(p, request)) || + tryExtensions(path.resolve(p, request)) || // try it with each of the extensions at "index" - tryExtensions(path.join(p, request, 'index')); + tryExtensions(path.resolve(p, request, 'index')); if (f) { return f; } } return false; @@ -220,7 +220,7 @@ // as it already has been accepted as a module. var isIndex = /^index\.\w+?$/.test(path.basename(parent.filename)), parentIdPath = isIndex ? parent.id : path.dirname(parent.id), - id = path.join(parentIdPath, request); + id = path.resolve(parentIdPath, request); // make sure require('./path') and require('path') get distinct ids, even // when called from the toplevel js file @@ -557,10 +557,9 @@ } else { // Load module - if ('/\\'.indexOf(process.argv[1].charAt(0)) < 0 - && process.argv[1].charAt(1) != ':' - && !(/^http:\/\//).exec(process.argv[1])) { - process.argv[1] = path.join(cwd, process.argv[1]); + // make process.argv[1] into a full path + if (!(/^http:\/\//).exec(process.argv[1])) { + process.argv[1] = path.resolve(process.argv[1]); } // REMOVEME: nextTick should not be necessary. This hack to get // test/simple/test-exception-handler2.js working.