🐛 Improve parse runtime env reading function

This commit is contained in:
Baptiste Arnaud
2023-08-28 14:19:40 +02:00
parent efd4600b7e
commit 036b407a11
8 changed files with 22 additions and 20 deletions

View File

@@ -4,11 +4,11 @@ import type { ScriptToExecute } from '@typebot.io/schemas'
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor
export const executeScript = async ({ content, args }: ScriptToExecute) => {
const func = AsyncFunction(
...args.map((arg) => arg.id),
parseContent(content)
)
try {
const func = AsyncFunction(
...args.map((arg) => arg.id),
parseContent(content)
)
await func(...args.map((arg) => arg.value))
} catch (err) {
console.error(err)