compiled src/coffee-script.coffee

This commit is contained in:
Michael Ficarra 2011-08-27 13:20:29 -04:00
parent 2ff6c4c3fc
commit 539b872e02
1 changed files with 10 additions and 9 deletions

View File

@ -58,20 +58,21 @@
}
};
exports.eval = function(code, options) {
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref2, _ref3, _ref4, _require;
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref2, _ref3, _require;
if (options == null) options = {};
if (!(code = code.trim())) return;
if (_ref2 = require('vm'), Script = _ref2.Script, _ref2) {
Script = require('vm').Script;
if (Script) {
sandbox = Script.createContext();
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
if (options.sandbox != null) {
if (options.sandbox instanceof sandbox.constructor) {
sandbox = options.sandbox;
} else {
_ref3 = options.sandbox;
for (k in _ref3) {
if (!__hasProp.call(_ref3, k)) continue;
v = _ref3[k];
_ref2 = options.sandbox;
for (k in _ref2) {
if (!__hasProp.call(_ref2, k)) continue;
v = _ref2[k];
sandbox[k] = v;
}
}
@ -85,9 +86,9 @@
return Module._load(path, _module);
};
_module.filename = sandbox.__filename;
_ref4 = Object.getOwnPropertyNames(require);
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
r = _ref4[_i];
_ref3 = Object.getOwnPropertyNames(require);
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
r = _ref3[_i];
if (r !== 'paths') _require[r] = require[r];
}
_require.paths = _module.paths = Module._nodeModulePaths(process.cwd());