summaryrefslogtreecommitdiff
path: root/lib/module.js
diff options
context:
space:
mode:
authorBradley Meck <bradley.meck@gmail.com>2015-08-11 20:25:49 -0400
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-08-24 10:46:14 -0400
commit2d251e661a8c761e0c1bd809fdc6a29179950c00 (patch)
treed2c48061fbada2bc44705f5ac6350c15619a6fb1 /lib/module.js
parent6480f422886e16c0fd620f24f3e3816b5760abc4 (diff)
downloadandroid-node-v8-2d251e661a8c761e0c1bd809fdc6a29179950c00.tar.gz
android-node-v8-2d251e661a8c761e0c1bd809fdc6a29179950c00.tar.bz2
android-node-v8-2d251e661a8c761e0c1bd809fdc6a29179950c00.zip
module: fix module preloading when cwd is ENOENT
Fixes a regression from 5759722cfacf17cc79651c81801a5e03521db053 that prevented modules from being preloaded if the cwd does not exist. Absolute and builtin modules now preload correctly again. Refs: https://github.com/nodejs/node/issues/1803 PR-URL: https://github.com/nodejs/node/pull/2353 Reviewed-By: Jeremiah Senkpiel <fishrock123@rockemail.com>
Diffstat (limited to 'lib/module.js')
-rw-r--r--lib/module.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/module.js b/lib/module.js
index fa7d5ebcda..aaa6220e40 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -515,9 +515,16 @@ Module._preloadModules = function(requests) {
// 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());
+ try {
+ parent.paths = Module._nodeModulePaths(process.cwd());
+ }
+ catch (e) {
+ if (e.code !== 'ENOENT') {
+ throw e;
+ }
+ }
requests.forEach(function(request) {
- Module._load(request, parent, false);
+ parent.require(request);
});
};