This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Module.globalPaths is still set to a read-only copy of the global include paths pulled off of the NODE_PATH environment variable. It's important to be able to inspect this, but modifying it no longer has any effect.
- Loading branch information
Showing
8 changed files
with
43 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ Module._contextLoad = (+process.env['NODE_MODULE_CONTEXTS'] > 0); | |
Module._cache = {}; | ||
Module._pathCache = {}; | ||
Module._extensions = {}; | ||
Module._paths = []; | ||
var modulePaths = []; | ||
Module.globalPaths = []; | ||
|
||
Module.wrapper = NativeModule.wrapper; | ||
Module.wrap = NativeModule.wrap; | ||
|
@@ -217,7 +218,7 @@ Module._resolveLookupPaths = function(request, parent) { | |
|
||
var start = request.substring(0, 2); | ||
if (start !== './' && start !== '..') { | ||
var paths = Module._paths; | ||
var paths = modulePaths; | ||
if (parent) { | ||
if (!parent.paths) parent.paths = []; | ||
paths = parent.paths.concat(paths); | ||
|
@@ -229,7 +230,7 @@ Module._resolveLookupPaths = function(request, parent) { | |
if (!parent || !parent.id || !parent.filename) { | ||
// make require('./path/to/foo') work - normally the path is taken | ||
// from realpath(__filename) but with eval there is no filename | ||
var mainPaths = ['.'].concat(Module._paths); | ||
var mainPaths = ['.'].concat(modulePaths); | ||
mainPaths = Module._nodeModulePaths('.').concat(mainPaths); | ||
return [request, mainPaths]; | ||
} | ||
|
@@ -353,15 +354,23 @@ Module.prototype._compile = function(content, filename) { | |
|
||
require.resolve = function(request) { | ||
return Module._resolveFilename(request, self)[1]; | ||
} | ||
require.paths = Module._paths; | ||
}; | ||
|
||
Object.defineProperty(require, 'paths', { get: function() { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
isaacs
Author
|
||
throw new Error('require.paths is removed. Use ' + | ||
'node_modules folders, or the NODE_PATH '+ | ||
'environment variable instead.'); | ||
}}); | ||
|
||
require.main = process.mainModule; | ||
|
||
// Enable support to add extra extension types | ||
require.extensions = Module._extensions; | ||
require.registerExtension = function() { | ||
throw new Error('require.registerExtension() removed. Use ' + | ||
'require.extensions instead.'); | ||
} | ||
}; | ||
|
||
require.cache = Module._cache; | ||
|
||
var dirname = path.dirname(filename); | ||
|
@@ -475,7 +484,10 @@ Module._initPaths = function() { | |
paths = process.env['NODE_PATH'].split(':').concat(paths); | ||
} | ||
|
||
Module._paths = paths; | ||
modulePaths = paths; | ||
|
||
// clone as a read-only copy, for introspection. | ||
Module.globalPaths = modulePaths.slice(0); | ||
}; | ||
|
||
// bootstrap repl | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shouldn't this be
set
, notget
? From the commit message: