bcoe / sandcastle

A simple and powerful sandbox for running untrusted JavaScript.
MIT License
220 stars 48 forks source link

Using console as an api #54

Closed cblavier closed 9 years ago

cblavier commented 9 years ago

Hey, I can't manage to expose console as an API (function is properly exposed, but nothing is printed to stdout)

Here is my api.js

exports.api = {
  console: console
};

And my code

var SandCastle = require('sandcastle').SandCastle;

var sandcastle = new SandCastle({
  api: './api.js'
});

var script = sandcastle.createScript("\
  exports.main = function() {\
    console.log('hello!');\
    exit();\
  }\
");

script.on('exit', function(err, output) {
  process.exit(0);
});

script.run();

Any help would be much appreciated :)

thedjpetersen commented 9 years ago

trying running your script with the DEBUG environment variable set to sandcastle -

ala DEBUG=sandcastle, node myscript.js

cblavier commented 9 years ago

Working fine :) Thanks!