diff options
author | Paddy Byers <paddy.byers@gmail.com> | 2011-11-23 03:46:01 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-02-01 05:50:11 +0400 |
commit | 840229a8251955d2b791928875f36d35127dcad0 (patch) | |
tree | 6e67579870c37c5f695f55aad2b40e59b6561f42 /lib | |
parent | 35b3d151949e023eee07c118bf89826519fee488 (diff) |
Tidy _resolveFilename
Diffstat (limited to 'lib')
-rw-r--r-- | lib/module.js | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/module.js b/lib/module.js index da67ef65d26..bbb1556bb82 100644 --- a/lib/module.js +++ b/lib/module.js @@ -276,18 +276,16 @@ Module._load = function(request, parent, isMain) { debug('Module._load REQUEST ' + (request) + ' parent: ' + parent.id); } - var resolved = Module._resolveFilename(request, parent); - var id = resolved[0]; - var filename = resolved[1]; + var filename = Module._resolveFilename(request, parent); var cachedModule = Module._cache[filename]; if (cachedModule) { return cachedModule.exports; } - if (NativeModule.exists(id)) { + if (NativeModule.exists(filename)) { // REPL is a special case, because it needs the real require. - if (id == 'repl') { + if (filename == 'repl') { var replModule = new Module('repl'); replModule._compile(NativeModule.getSource('repl'), 'repl.js'); NativeModule._cache.repl = replModule; @@ -295,10 +293,10 @@ Module._load = function(request, parent, isMain) { } debug('load native module ' + request); - return NativeModule.require(id); + return NativeModule.require(filename); } - var module = new Module(id, parent); + var module = new Module(filename, parent); if (isMain) { process.mainModule = module; @@ -318,7 +316,7 @@ Module._load = function(request, parent, isMain) { Module._resolveFilename = function(request, parent) { if (NativeModule.exists(request)) { - return [request, request]; + return request; } var resolvedModule = Module._resolveLookupPaths(request, parent); @@ -333,8 +331,7 @@ Module._resolveFilename = function(request, parent) { if (!filename) { throw new Error("Cannot find module '" + request + "'"); } - id = filename; - return [id, filename]; + return filename; }; @@ -374,7 +371,7 @@ Module.prototype._compile = function(content, filename) { } require.resolve = function(request) { - return Module._resolveFilename(request, self)[1]; + return Module._resolveFilename(request, self); }; Object.defineProperty(require, 'paths', { get: function() { |