Skip to content

Commit

Permalink
Eval src using vm instead of compile for node >= 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Wolff authored and mhevery committed Dec 31, 2010
1 parent 03f1846 commit a82a8fe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/jasmine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ global.window = {
setInterval: setInterval,
clearInterval: clearInterval
};

var src = fs.readFileSync(filename);
var jasmine = process.compile(src + '\njasmine;', filename);
var jasmine;
minorVersion = process.version.match(/\d\.(\d)\.\d/)[1]
switch (minorVersion) {
case "1":
case "2":
jasmine = process.compile(src + '\njasmine;', filename);
break;
default:
jasmine = require('vm').runInThisContext(src + "\njasmine;", filename);
}

delete global.window;

function noop(){}
Expand Down

0 comments on commit a82a8fe

Please sign in to comment.