How to use the vm.runInNewContext function in vm

To help you get started, we’ve selected a few vm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jhanssen / jsh / src / node_modules / Service / Service.js View on Github external
then(function(script) {
                script = 'var module={};' + script + '(function(){var f=[];for(var i in module.exports){if(typeof(module.exports[i])===\'function\')f.push(i);} return f;})()';
                // jsh.log('running script', script);
                functions = vm.runInNewContext(script, undefined, serviceFile); // no async API for this?
                jsh.log('GOT FUNCTIONS', functions);
                return writeFile(manifestFile, functions.join(' '));
            }).
            then(function(err) {
github batiste / CokeScript / test / basics.js View on Github external
function exe(js, context) {
  try {
    return vm.runInNewContext(js, context);
  } catch(e) {
    throw 'JS error\n' + js;
  }
}
github duojs / duo / test / cli.js View on Github external
function evaluate(js, ctx) {
  if (!ctx) ctx = { window: {}, document: {} };
  js = convert.removeComments(js);
  vm.runInNewContext('main =' + js + '(1)', ctx, 'main.vm');
  vm.runInNewContext('require =' + js + '', ctx, 'require.vm');
  return ctx;
}
github Clouda-team / Cloudajs / sumeru / server / readClientFile.js View on Github external
var runnable = function(path, context) {
  var data = fs.readFileSync(path);
  if (!context)context ={};
  context.console=console;
  vm.runInNewContext(data, context, path);
}
var _getFilePackageByPath = function(path,filename){
github rethinkdb / horizon / plugins / src / permissions / template.js View on Github external
const make_template = (str) => {
  try {
    const sandbox = Object.assign({}, env);
    return vm.runInNewContext(str, sandbox);
  } catch (err) {
    throw remakeError(err);
  }
};

vm

NodeJS Core Module Extended

MIT
Latest version published 9 years ago

Package Health Score

47 / 100
Full package analysis