Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
}
});
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) {
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) {
function load(filename) {
var code = FS.readFileSync(PATH.join(__dirname, filename));
VM.runInContext(code, context, filename);
}