-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheval.lua
More file actions
36 lines (30 loc) · 835 Bytes
/
eval.lua
File metadata and controls
36 lines (30 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local runner = require("eval_runner")
local json = require("json")
local function call(arguments)
local source = arguments.source
if not source or source == "" then
return "Error: source is required"
end
local opts = {
source = source,
modules = arguments.modules or {},
args = arguments.args or {},
context = arguments.context or {},
allow_classes = arguments.allow_classes or {}
}
if arguments.method and arguments.method ~= "" then
opts.method = arguments.method
end
local result, err = runner.run(opts)
if err then
return json.encode({
success = false,
error = tostring(err)
})
end
return json.encode({
success = true,
result = result
})
end
return { call = call }