summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYosuke Furukawa <yosuke.furukawa@gmail.com>2015-05-14 00:00:57 +0900
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-05-15 17:40:03 -0400
commit0a461e5360f400e42a144ad968bcfa9e72e42668 (patch)
treee81ac32d4c7ff6915b6e00fdf86c915aa55e73f4
parent8a0e5295b4c0b83855d4b51496254a759dfe9dfa (diff)
downloadnode-new-0a461e5360f400e42a144ad968bcfa9e72e42668.tar.gz
src: fix preload when used with prior flags
Fixes: https://github.com/nodejs/io.js/issues/1691 PR-URL: https://github.com/nodejs/io.js/pull/1694 Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
-rw-r--r--src/node.js21
-rw-r--r--test/parallel/test-preload.js12
2 files changed, 24 insertions, 9 deletions
diff --git a/src/node.js b/src/node.js
index 55b1d782ce..cb50341ce2 100644
--- a/src/node.js
+++ b/src/node.js
@@ -82,16 +82,9 @@
delete process.env.NODE_UNIQUE_ID;
}
- // Load any preload modules
- if (process._preload_modules) {
- var Module = NativeModule.require('module');
- process._preload_modules.forEach(function(module) {
- Module._load(module);
- });
- }
-
if (process._eval != null) {
// User passed '-e' or '--eval' arguments to Node.
+ startup.preloadModules();
evalScript('[eval]');
} else if (process.argv[1]) {
// make process.argv[1] into a full path
@@ -99,7 +92,7 @@
process.argv[1] = path.resolve(process.argv[1]);
var Module = NativeModule.require('module');
-
+ startup.preloadModules();
if (global.v8debug &&
process.execArgv.some(function(arg) {
return arg.match(/^--debug-brk(=[0-9]*)?$/);
@@ -857,6 +850,16 @@
};
};
+ // Load preload modules
+ startup.preloadModules = function() {
+ if (process._preload_modules) {
+ var Module = NativeModule.require('module');
+ process._preload_modules.forEach(function(module) {
+ Module._load(module);
+ });
+ }
+ };
+
// Below you find a minimal module system, which is used to load the node
// core modules found in lib/*.js. All core modules are compiled into the
// node binary, so they can be loaded faster.
diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js
index 643edfb1d9..3801f3df7b 100644
--- a/test/parallel/test-preload.js
+++ b/test/parallel/test-preload.js
@@ -80,3 +80,15 @@ child_process.exec(nodeBinary + ' '
if (err) throw err;
assert.ok(/worker terminated with code 43/.test(stdout));
});
+
+// https://github.com/iojs/io.js/issues/1691
+var originalCwd = process.cwd();
+process.chdir(path.join(__dirname, '../fixtures/'));
+child_process.exec(nodeBinary + ' '
+ + '--expose_debug_as=v8debug '
+ + '--require ' + fixture('cluster-preload.js') + ' '
+ + 'cluster-preload-test.js',
+ function(err, stdout, stderr) {
+ if (err) throw err;
+ assert.ok(/worker terminated with code 43/.test(stdout));
+ });