Skip to content

Commit c779b78

Browse files
committed
fix: simplify js wrapper
1 parent 6e7cf6c commit c779b78

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

internal/runtime/langs.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ import _ from 'lodash';
4242
4343
const consoleRegex = /console\.(log|debug|info|warn|error|table|trace|group|groupEnd|time|timeEnd)\s*\([^;]*\);?/g;
4444
45+
async function ExecutronExecuteJsCode() {
46+
%s
47+
}
48+
4549
try {
46-
const result = await eval('(async () => { %s })()');
47-
console.log(JSON.stringify({ result: result.toString() }));
50+
const result = await ExecutronExecuteJsCode()
51+
console.log(JSON.stringify({ result: result.toString().replace(consoleRegex, '') }));
4852
} catch (e) {
4953
console.log(JSON.stringify({ error: e.message }));
5054
}
@@ -73,7 +77,7 @@ try {
7377
}
7478

7579
func createPyContext(code string) *containerContext {
76-
codeLines := []string{}
80+
var codeLines []string
7781
for _, line := range strings.Split(code, "\n") {
7882
codeLines = append(codeLines, fmt.Sprintf(" %s", line))
7983
}

0 commit comments

Comments
 (0)