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
1 changed files with 9 additions and 2 deletions

View File

@ -1,11 +1,18 @@
import { Ctx } from "@budibase/types" import { Ctx } from "@budibase/types"
import { IsolatedVM } from "../../jsRunner/vm" import { IsolatedVM } from "../../jsRunner/vm"
import { iifeWrapper } from "@budibase/string-templates" import { iifeWrapper, UserScriptError } from "@budibase/string-templates"
export async function execute(ctx: Ctx) { export async function execute(ctx: Ctx) {
const { script, context } = ctx.request.body const { script, context } = ctx.request.body
const vm = new IsolatedVM() const vm = new IsolatedVM()
try {
ctx.body = vm.withContext(context, () => vm.execute(iifeWrapper(script))) 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) { export async function save(ctx: Ctx) {