Skip to content

Instantly share code, notes, and snippets.

@rehanift
Created October 30, 2011 20:52
Show Gist options
  • Save rehanift/1326427 to your computer and use it in GitHub Desktop.
Save rehanift/1326427 to your computer and use it in GitHub Desktop.
engine.js locals demo
var engine = require("./engine").engine;
var client, task, intake, exhaust, cylinder, logging_gateway, stdout_client, logging_opts;
logging_gateway = engine.logging_gateway.create();
stdout_client = engine.logging_stdout_client.create();
logging_gateway.add_logger(stdout_client);
logging_opts = {
logging_gateway: logging_gateway
};
intake = engine.intake.create(logging_opts);
exhaust = engine.exhaust.create(logging_opts);
cylinder = engine.cylinder.create(logging_opts);
client = engine.client.create();
task = client.createTask();
task.setContext('(function(locals){ return { getAccount: function(){ return locals.account_id } } })');
task.setLocals({ account_id: 123 });
task.setCode('console.log(process)');
task.on('eval', function(data){
console.log('eval:', data);
});
task.on('output', function(data){
console.log('console:', data);
});
task.run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment