I wanted to know what you mean by "redirect to events" when using the redirect
option for console in NodeVM
. I have always used the sandbox method, of just attaching a console object with its own methods, however I wanted to know if there was an alternative cleaner solution
It's working like this:
const vm = new NodeVM({
console: 'redirect'
});
vm.on('console.log', (msg) => {
console.log('REDIRECTED:', msg);
})
vm.run("console.log('hello');");
You can listen for those events:
console.log
console.info
console.warn
console.error
console.dir
console.trace
Awesome thanks!
Thanks! maybe we can add this to README or other documentation?
Most helpful comment
It's working like this:
You can listen for those events:
console.log
console.info
console.warn
console.error
console.dir
console.trace