summaryrefslogtreecommitdiff
path: root/src/node.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-08-03 16:23:14 -0700
committerisaacs <i@izs.me>2012-08-03 16:23:14 -0700
commit3bf1846bb7653af718d8d5bf4e75d904b2ac285f (patch)
treeff06f5873e27750f2e2af37f7019d00f3f9bf814 /src/node.js
parentc05f52c254a070f8b58f12b37687d4e40a0edb8e (diff)
parent5fdeebd94d58bf715d991d5bc63be6fff507f27d (diff)
downloadnode-new-3bf1846bb7653af718d8d5bf4e75d904b2ac285f.tar.gz
Merge remote-tracking branch 'ry/v0.8'
Conflicts: ChangeLog deps/uv/src/unix/sunos.c deps/uv/test/test-tcp-unexpected-read.c src/node_version.h
Diffstat (limited to 'src/node.js')
-rw-r--r--src/node.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/node.js b/src/node.js
index 466387169b..848c39d119 100644
--- a/src/node.js
+++ b/src/node.js
@@ -74,7 +74,7 @@
} else if (process._eval != null) {
// User passed '-e' or '--eval' arguments to Node.
- evalScript('eval');
+ evalScript('[eval]');
} else if (process.argv[1]) {
// make process.argv[1] into a full path
var path = NativeModule.require('path');
@@ -355,7 +355,19 @@
var module = new Module(name);
module.filename = path.join(cwd, name);
module.paths = Module._nodeModulePaths(cwd);
- var result = module._compile('return eval(process._eval)', name);
+ var script = process._eval;
+ if (!Module._contextLoad) {
+ var body = script;
+ script = 'global.__filename = ' + JSON.stringify(name) + ';\n' +
+ 'global.exports = exports;\n' +
+ 'global.module = module;\n' +
+ 'global.__dirname = __dirname;\n' +
+ 'global.require = require;\n' +
+ 'return require("vm").runInThisContext(' +
+ JSON.stringify(body) + ', ' +
+ JSON.stringify(name) + ', true);\n';
+ }
+ var result = module._compile(script, name + '-wrapper');
if (process._print_eval) console.log(result);
}