From 3a00470dbb0ac1ead14b52624b16e917e522fddf Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 14 Jul 2010 14:22:58 -0700 Subject: [PATCH] Add 'root' global variable as reference to sandbox --- lib/module.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/module.js b/lib/module.js index 6ff17e9af33..9d041999da6 100644 --- a/lib/module.js +++ b/lib/module.js @@ -400,6 +400,7 @@ Module.prototype._compile = function (content, filename) { sandbox.__filename = filename; sandbox.__dirname = dirname; sandbox.module = self; + sandbox.root = sandbox; Script.runInNewContext(content, sandbox, filename); @@ -411,6 +412,7 @@ Module.prototype._compile = function (content, filename) { global.__filename = filename; global.__dirname = dirname; global.module = self; + global.root = global; Script.runInThisContext(content, filename); }