From 037dedd1626c62c59c1531b2ce86f70418cd543f Mon Sep 17 00:00:00 2001 From: Brian Seymour Date: Thu, 21 Jan 2021 19:07:23 -0600 Subject: [PATCH] remove temp file after running --- shared/execute.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/shared/execute.js b/shared/execute.js index 188a123..6547ca8 100644 --- a/shared/execute.js +++ b/shared/execute.js @@ -1,4 +1,4 @@ -const { writeFileSync } = require('fs'); +const { writeFileSync, unlinkSync } = require('fs'); const { spawn } = require('child_process'); function execute(language, source, stdin = '', args = []) { @@ -28,8 +28,10 @@ function execute(language, source, stdin = '', args = []) { stdout += chunk; output += chunk; }); - + process.on('exit', code => { + unlinkSync(sourceFile); + stderr = stderr.trim().substring(0, 65535); stdout = stdout.trim().substring(0, 65535); output = output.trim().substring(0, 65535);