From e2b3eeeff11e424ee9626827ebda9046e6ac1f77 Mon Sep 17 00:00:00 2001 From: satyr Date: Wed, 11 Apr 2012 18:39:52 +0900 Subject: [PATCH] node: ensured bare compilation on `.run` --- lib/node.js | 9 +++++++-- src/node.co | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/node.js b/lib/node.js index 2ddbc5c1e..e697a22d3 100644 --- a/lib/node.js +++ b/lib/node.js @@ -4,7 +4,7 @@ module.exports = function(Coco){ fs = require('fs'); path = require('path'); Coco.run = function(code, options, js){ - var filename, main, dirname; + var filename, main, dirname, __ref; if (options != null) { filename = options.filename; } @@ -16,7 +16,7 @@ module.exports = function(Coco){ } main.paths = main.constructor._nodeModulePaths(dirname); main.filename = filename; - js || (code = Coco.compile(code, options)); + js || (code = Coco.compile(code, (__ref = {}, __import(__ref, options), __ref.bare = true, __ref))); try { return main._compile(code, filename); } catch (e) { @@ -66,6 +66,11 @@ function hackTrace(error, js, filename){ } return error.stack = traces.join('\n'), error; } +function __import(obj, src){ + var own = {}.hasOwnProperty; + for (var key in src) if (own.call(src, key)) obj[key] = src[key]; + return obj; +} function __importAll(obj, src){ for (var key in src) obj[key] = src[key]; return obj; diff --git a/src/node.co b/src/node.co index ebcc9c124..e5068a40f 100644 --- a/src/node.co +++ b/src/node.co @@ -17,7 +17,7 @@ module.exports = !(Coco) -> dirname = filename = \. main.paths = main.._nodeModulePaths dirname main <<< {filename} - js or code = Coco.compile code, options + js or code = Coco.compile code, {...options, +bare} try main._compile code, filename catch throw hackTrace e, code, filename Coco import all require(\events)EventEmitter::