mirror of
https://github.com/penpot/penpot-mcp.git
synced 2026-04-25 11:18:37 +00:00
ExecuteCodeTaskHandler: Await result if it is a Promise
This commit is contained in:
parent
4350f18ab3
commit
13cb1aee0f
@ -193,10 +193,16 @@ export class ExecuteCodeTaskHandler extends TaskHandler<ExecuteCodeTaskParams> {
|
||||
const context = this.context;
|
||||
const code = task.params.code;
|
||||
|
||||
const result = (function (ctx) {
|
||||
let result: any = (function (ctx) {
|
||||
return Function(...Object.keys(ctx), code)(...Object.values(ctx));
|
||||
})(context);
|
||||
|
||||
// if the result is a Promise, await it
|
||||
if (result instanceof Promise) {
|
||||
console.log("Code execution returned a Promise, awaiting result...");
|
||||
result = await result;
|
||||
}
|
||||
|
||||
console.log("Code execution result:", result);
|
||||
|
||||
// return both result and captured log
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user