From e637a95b335a361cb754c8e0932accca64d34dd4 Mon Sep 17 00:00:00 2001 From: Vrganj Date: Sun, 17 Jan 2021 01:12:13 +0000 Subject: [PATCH] Make execute.js support older Node versions --- shared/execute.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared/execute.js b/shared/execute.js index 4124928..188a123 100644 --- a/shared/execute.js +++ b/shared/execute.js @@ -1,18 +1,18 @@ -const { writeFile } = require('fs/promises'); +const { writeFileSync } = require('fs'); const { spawn } = require('child_process'); -function execute(language, source, stdin, args) { - return new Promise(async resolve => { +function execute(language, source, stdin = '', args = []) { + return new Promise(resolve => { const stamp = new Date().getTime(); const sourceFile = `/tmp/${stamp}.code`; - await writeFile(sourceFile, source); + writeFileSync(sourceFile, source); const process = spawn(__dirname + '/../lxc/execute', [ language.name, sourceFile, - stdin ?? '', - args?.join('\n') ?? '', + stdin, + args.join('\n'), ]); let stdout = '';