remove temp file after running

This commit is contained in:
Brian Seymour 2021-01-21 19:07:23 -06:00
parent b85605a340
commit 037dedd162
1 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,4 @@
const { writeFileSync } = require('fs'); const { writeFileSync, unlinkSync } = require('fs');
const { spawn } = require('child_process'); const { spawn } = require('child_process');
function execute(language, source, stdin = '', args = []) { function execute(language, source, stdin = '', args = []) {
@ -28,8 +28,10 @@ function execute(language, source, stdin = '', args = []) {
stdout += chunk; stdout += chunk;
output += chunk; output += chunk;
}); });
process.on('exit', code => { process.on('exit', code => {
unlinkSync(sourceFile);
stderr = stderr.trim().substring(0, 65535); stderr = stderr.trim().substring(0, 65535);
stdout = stdout.trim().substring(0, 65535); stdout = stdout.trim().substring(0, 65535);
output = output.trim().substring(0, 65535); output = output.trim().substring(0, 65535);