aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-10-26 08:32:36 +0800
committersigoden <sigoden@gmail.com>2024-10-26 08:32:36 +0800
commit602ca0535e8d79e1e9362f870e3583e5bbedfe5b (patch)
tree0cec1846f5fffbc43501db2f47de60c5518d27b7
parente1a26cb4f2032dfb44908ecb73b9039ca1c7dc04 (diff)
downloadllm-functions-docker-602ca0535e8d79e1e9362f870e3583e5bbedfe5b.tar.gz
chore: execute js/py code
-rw-r--r--tools/execute_js_code.js6
-rw-r--r--tools/execute_py_code.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/tools/execute_js_code.js b/tools/execute_js_code.js
index 3ca0401..6f04ade 100644
--- a/tools/execute_js_code.js
+++ b/tools/execute_js_code.js
@@ -5,15 +5,15 @@
* @param {Args} args
*/
exports.run = function run({ code }) {
- let log = "";
+ let output = "";
const oldStdoutWrite = process.stdout.write.bind(process.stdout);
process.stdout.write = (chunk, _encoding, callback) => {
- log += chunk;
+ output += chunk;
if (callback) callback();
};
eval(code);
process.stdout.write = oldStdoutWrite;
- return log;
+ return output;
}
diff --git a/tools/execute_py_code.py b/tools/execute_py_code.py
index ad9310c..a8cfe48 100644
--- a/tools/execute_py_code.py
+++ b/tools/execute_py_code.py
@@ -7,10 +7,10 @@ def run(code: str):
code: Python code to execute, such as `print("hello world")`
"""
old_stdout = sys.stdout
- new_stdout = io.StringIO()
- sys.stdout = new_stdout
+ output = io.StringIO()
+ sys.stdout = output
exec(code)
sys.stdout = old_stdout
- return new_stdout.getvalue() \ No newline at end of file
+ return output.getvalue() \ No newline at end of file