Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pluginNames.map(function(pluginName) {
var pluginId = plugins[cat][pluginName]
var pluginSourcePath = pluginsPath+'/'+pluginId+'.plugin.js'
var pluginSource = fs.readFileSync(pluginSourcePath)
pluginSource += ';\n'
pluginSource += 'var fakeNode = new Node(E2.core.root_graph, "'+pluginId+'");\n'
pluginSource += 'var plugin = new E2.plugins.'+pluginId+'(E2.core, fakeNode);\n'
script = new vm.Script(pluginSource, { filename: pluginId })
script.runInContext(context)
sandbox.plugin.input_slots.map(seenSlot(pluginId, 0))
sandbox.plugin.output_slots.map(seenSlot(pluginId, 1))
})
})
function getCompiledScript (filename) {
if (compiledScripts[filename]) {
return compiledScripts[filename]
}
const code = files[filename]
const wrapper = NativeModule.wrap(code)
const script = new vm.Script(wrapper, {
filename,
displayErrors: true
})
compiledScripts[filename] = script
return script
}
function getCompiledScript (filename) {
if (compiledScripts[filename]) {
return compiledScripts[filename]
}
const code = files[filename]
const wrapper = NativeModule.wrap(code)
const script = new vm.Script(wrapper, {
filename,
displayErrors: true
})
compiledScripts[filename] = script
return script
}
const evaluate = async (line: string) => {
line = wrapIfNeeded(line)
const script = new Script(line)
try {
const output = await script.runInContext(context)
context._ = output
return {output}
} catch (error) {
return {error}
}
}
static getSelectAdapter(info, rs) {
const columns = rs.columns;
if (!columns) {
throw new Error('Expected ROWS result obtained VOID');
}
let scriptText = '(function rowAdapter(row, info) {\n' +
' const item = info.newInstance();\n';
scriptText += columns.map(c => ` item['${info.getPropertyName(c.name)}'] = row['${c.name}'];`).join('\n');
scriptText += '\n return item;\n})';
const script = new vm.Script(scriptText);
return script.runInThisContext({ filename: 'gen-result-mapper.js'});
}