embark-area-51/lib/coderunner/codeRunner.js

25 lines
429 B
JavaScript
Raw Normal View History

2018-05-21 21:22:19 +00:00
let __mainContext;
class CodeRunner {
constructor(options) {
this.plugins = options.plugins;
this.logger = options.logger;
this.events = options.events;
}
registerVar(varName, code) {
__mainContext[varName] = code;
}
doEval(code) {
try {
// TODO: add trace log here
return eval(code);
} catch(e) {
throw new Error(e + "\n" + code);
}
}
}
module.exports = CodeRunner;