Skip to content

Commit

Permalink
node: ensured bare compilation on .run
Browse files Browse the repository at this point in the history
  • Loading branch information
satyr committed Apr 11, 2012
1 parent 4bbb522 commit e2b3eee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/node.co
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down

0 comments on commit e2b3eee

Please sign in to comment.