Fix automation tests.
This commit is contained in:
parent
19f58b62c9
commit
831c81a99c
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue