Skip to content
Browse files

Dav's fixes to make yuitest work in Node < 0.3.0

  • Loading branch information...
1 parent 5e24913 commit f39550430783cbdae70e66ca2a2478f7ce221711 nzakas committed
Showing with 22 additions and 4 deletions.
  1. +11 −2 javascript/build/yuitest/npm/cli.js
  2. +11 −2 javascript/src/nodejs/cli.js
View
13 javascript/build/yuitest/npm/cli.js
@@ -4,13 +4,18 @@
var fs = require("fs"),
path = require("path"),
- vm = require("vm"),
+ vm = null,
YUITest = require("./lib/yuitest-node.js").YUITest,
TestRunner = YUITest.TestRunner,
stdout = process.stdout,
stderr = process.stderr;
+ if (process.binding("natives").vm){
+ vm = require("vm");
+ }
+
+
//options collected from command line
var options = {
verbose: false,
@@ -132,7 +137,11 @@ if (files.length){
if (options.webcompat){
output = fs.readFileSync(files[i]);
- vm.runInThisContext("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ if (vm){
+ vm.runInThisContext("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ } else {
+ process.compile("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ }
} else {
try {
require(files[i]);
View
13 javascript/src/nodejs/cli.js
@@ -4,13 +4,18 @@
var fs = require("fs"),
path = require("path"),
- vm = require("vm"),
+ vm = null,
YUITest = require("./lib/yuitest-node.js").YUITest,
TestRunner = YUITest.TestRunner,
stdout = process.stdout,
stderr = process.stderr;
+ if (process.binding("natives").vm){
+ vm = require("vm");
+ }
+
+
//options collected from command line
var options = {
verbose: false,
@@ -132,7 +137,11 @@ if (files.length){
if (options.webcompat){
output = fs.readFileSync(files[i]);
- vm.runInThisContext("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ if (vm){
+ vm.runInThisContext("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ } else {
+ process.compile("(function(YUITest){\n" + output + "\n})", files[i])(YUITest);
+ }
} else {
try {
require(files[i]);

0 comments on commit f395504

Please sign in to comment.
Something went wrong with that request. Please try again.