1
0
Fork 0

Now using vm module in node instead of process.binding.Script (deprecated in newer versions of node)

closure/master
Mike Gerwitz 2011-12-04 12:50:01 -05:00
parent 27eea93d6f
commit 1a3b5f2893
5 changed files with 12 additions and 9 deletions

View File

@ -36,7 +36,7 @@ var _handler = null;
* *
* @type {Object} * @type {Object}
*/ */
var _console = console; var _console = ( typeof console !== 'undefined' ) ? console : undefined;
/** /**

View File

@ -29,14 +29,15 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
vm = require( 'vm' ),
Class = common.require( 'class' ), Class = common.require( 'class' ),
Script = process.binding( 'evals' ).Script,
// sandbox in which combined script will be run // sandbox in which combined script will be run
sandbox = { sandbox = vm.createContext( {
// stub document.write() so we don't blow up // stub document.write() so we don't blow up
document: { write: function() {} }, document: { write: function() {} },
}; runTests: null,
} );
var file = 'ease-full.js'; var file = 'ease-full.js';
@ -69,8 +70,7 @@ data = "delete Object.defineProperty;" +
; ;
// run the script (if this fails to compile, the generated code is invalid) // run the script (if this fails to compile, the generated code is invalid)
var cmb_script = new Script( data ); vm.runInNewContext( data, sandbox );
cmb_script.runInNewContext( sandbox );
// cross your fingers // cross your fingers
sandbox.easejs.runTests(); sandbox.easejs.runTests();

View File

@ -24,8 +24,8 @@
var common = require( './common' ), var common = require( './common' ),
assert = require( 'assert' ), assert = require( 'assert' ),
vm = require( 'vm' ),
Class = common.require( 'class' ), Class = common.require( 'class' ),
Script = process.binding( 'evals' ).Script,
// sandbox in which combined script will be run // sandbox in which combined script will be run
sandbox = { sandbox = {
@ -60,8 +60,7 @@ while ( i-- )
} }
// run the script (if this fails to compile, the generated code is invalid) // run the script (if this fails to compile, the generated code is invalid)
var cmb_script = new Script( data ); vm.runInNewContext( data, sandbox );
cmb_script.runInNewContext( sandbox );
assert.equal( assert.equal(
sandbox.require, sandbox.require,

View File

@ -30,6 +30,8 @@ var common = require( './common' ),
warning = Warning( Error( 'gninraw' ) ) warning = Warning( Error( 'gninraw' ) )
; ;
if ( typeof console === 'undefined' ) console = undefined;
/** /**
* The log warning handler should log warnings to the console * The log warning handler should log warnings to the console

View File

@ -27,6 +27,8 @@ var common = require( './common' ),
warn = common.require( 'warn' ) warn = common.require( 'warn' )
; ;
if ( typeof console === 'undefined' ) console = undefined;
/** /**
* The default warning handler should be the 'log' handler. This is a friendly * The default warning handler should be the 'log' handler. This is a friendly