Spaces:
Paused
Paused
| import { exec } from "child_process"; | |
| export function runCode(code) { | |
| return new Promise((resolve) => { | |
| exec( | |
| `node -e "${code.replace(/"/g, '\\"')}"`, | |
| { timeout: 2500 }, | |
| (err, stdout, stderr) => { | |
| if (err) return resolve({ error: stderr || "Crash" }); | |
| resolve({ output: stdout }); | |
| } | |
| ); | |
| }); | |
| } |