diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-05-27 10:11:30 -0700 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2015-05-30 10:36:09 -0400 |
commit | 5759722cfacf17cc79651c81801a5e03521db053 (patch) | |
tree | b4bb49403e7346dd166f64820ef7e2adff284a85 /lib/module.js | |
parent | 53e98cc1b44203147c0abdc03eb0e57e34c4274d (diff) | |
download | android-node-v8-5759722cfacf17cc79651c81801a5e03521db053.tar.gz android-node-v8-5759722cfacf17cc79651c81801a5e03521db053.tar.bz2 android-node-v8-5759722cfacf17cc79651c81801a5e03521db053.zip |
src: fix module search path for preload modules
When the preload module is not a abs/relative path, we should use
the standard search mechanism of looking into the node_modules folders
outwards. The current working directory is deemed to be the 'requiring
module', i.e. parent. The search path starts from cwd outwards.
Fixes: https://github.com/nodejs/io.js/issues/1803
PR-URL: https://github.com/nodejs/io.js/pull/1812
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r-- | lib/module.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/module.js b/lib/module.js index 65e44b60b1..844b683940 100644 --- a/lib/module.js +++ b/lib/module.js @@ -503,6 +503,20 @@ Module.requireRepl = function() { return Module._load('internal/repl', '.'); }; +Module._preloadModules = function(requests) { + if (!Array.isArray(requests)) + return; + + // Preloaded modules have a dummy parent module which is deemed to exist + // in the current working directory. This seeds the search path for + // preloaded modules. + var parent = new Module('internal/preload', null); + parent.paths = Module._nodeModulePaths(process.cwd()); + requests.forEach(function(request) { + Module._load(request, parent, false); + }); +}; + Module._initPaths(); // backwards compatibility |