Skip to content

Instantly share code, notes, and snippets.

@dominictarr
Created December 19, 2010 11:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominictarr/747281 to your computer and use it in GitHub Desktop.
Save dominictarr/747281 to your computer and use it in GitHub Desktop.
module where globals === this
console.log("GLOBALS!")
var assert = require('assert')
this.hello = 'sdgfasdgaghasdg'
assert.ok(global === this,'expected global === this')
assert.equal(this.hello , hello)
y = 'MVOISMDFOVISR'
assert.equal(this.y , 'MVOISMDFOVISR')
//loader
require.extensions['.this-js'] =
function (module, filename) {
var content = require('fs').readFileSync(filename, 'utf8');
var newContent = "var globalizer = function () {"
+ content
+ "};\n globalizer.apply(global)"
module._compile(newContent, filename);
}
require('./globals')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment