Add 'root' global variable as reference to sandbox
authorRyan Dahl <ry@tinyclouds.org>
Wed, 14 Jul 2010 21:22:58 +0000 (14:22 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Thu, 15 Jul 2010 17:35:29 +0000 (10:35 -0700)
lib/module.js

index 6ff17e9af33f526004c12e0a55306cf77e42553f..9d041999da6fab52f40b496847cd777400c920f8 100644 (file)
@@ -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);
     }