How to use the vm.runInContext 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 k0sukey / ti-slag / index.js View on Github external
require: function(original){
				var source = path.resolve(path.join(path.dirname(file), original + '.js')),
					newcontext;

				if (_.has(options.module, original)) {
					return options.module[original];
				} else if (fs.existsSync(source)) {
					newcontext = createContext();
					vm.runInContext(fs.readFileSync(source, 'utf8'), newcontext);

					return _.isEmpty(newcontext.exports) ? newcontext.module.exports : newcontext.exports;
				} else {
					throw new Error('Unknown module detect ' + original);
				}
			}
		});
github SeleniumHQ / selenium / javascript / node / selenium-webdriver / firefox / profile.js View on Github external
function onSuccess(contents) {
        var prefs = {};
        var context = vm.createContext({
          'user_pref': function(key, value) {
            prefs[key] = value;
          }
        });
        vm.runInContext(contents.toString(), context, f);
        return prefs;
      },
      function onError(err) {
github jamesshore / lets_code_javascript / node_modules / selenium-webdriver / firefox / profile.js View on Github external
function onSuccess(contents) {
        var prefs = {};
        var context = vm.createContext({
          'user_pref': function(key, value) {
            prefs[key] = value;
          }
        });
        vm.runInContext(contents.toString(), context, f);
        return prefs;
      },
      function onError(err) {
github Stuk / jszip / index.js View on Github external
function load(filename) {
    var code = FS.readFileSync(PATH.join(__dirname, filename));
    VM.runInContext(code, context, filename);
}

vm

NodeJS Core Module Extended

MIT
Latest version published 8 years ago

Package Health Score

47 / 100
Full package analysis