1
0
Fork 0
mirror of synced 2024-10-05 04:25:21 +13:00

Fix automation tests.

This commit is contained in:
Sam Rose 2024-10-04 09:31:42 +01:00
parent 19f58b62c9
commit 831c81a99c
No known key found for this signature in database

View file

@ -1,11 +1,18 @@
import { Ctx } from "@budibase/types"
import { IsolatedVM } from "../../jsRunner/vm"
import { iifeWrapper } from "@budibase/string-templates"
import { iifeWrapper, UserScriptError } from "@budibase/string-templates"
export async function execute(ctx: Ctx) {
const { script, context } = ctx.request.body
const vm = new IsolatedVM()
try {
ctx.body = vm.withContext(context, () => vm.execute(iifeWrapper(script)))
} catch (err: any) {
if (err.code === UserScriptError.code) {
throw err.userScriptError
}
throw err
}
}
export async function save(ctx: Ctx) {