Created
March 3, 2011 11:20
-
-
Save kratkar/852634 to your computer and use it in GitHub Desktop.
runInNewContext
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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