Skip to content

Instantly share code, notes, and snippets.

@kratkar
Created March 3, 2011 11:20
Show Gist options
  • Save kratkar/852634 to your computer and use it in GitHub Desktop.
Save kratkar/852634 to your computer and use it in GitHub Desktop.
runInNewContext
var codes = [];
fs.readdirSync(app_root + '/app/models/').forEach(function (file) {
var fileModel = app_root + '/app/models/' + file;
codes.push({
'file' : fileModel,
'text' : fs.readFileSync(fileModel).toString('utf-8')
});
});
var scripts = [];
for(var i; i<codes.length; i++){
scripts[i] = vm.createScript(codes[i]['text'], codes[i]['file'])
}
scripts.forEach(function(script){
script.runInNewContext(context)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment