Make execute.js support older Node versions
This commit is contained in:
parent
008d55643b
commit
e637a95b33
|
@ -1,18 +1,18 @@
|
||||||
const { writeFile } = require('fs/promises');
|
const { writeFileSync } = require('fs');
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
function execute(language, source, stdin, args) {
|
function execute(language, source, stdin = '', args = []) {
|
||||||
return new Promise(async resolve => {
|
return new Promise(resolve => {
|
||||||
const stamp = new Date().getTime();
|
const stamp = new Date().getTime();
|
||||||
const sourceFile = `/tmp/${stamp}.code`;
|
const sourceFile = `/tmp/${stamp}.code`;
|
||||||
|
|
||||||
await writeFile(sourceFile, source);
|
writeFileSync(sourceFile, source);
|
||||||
|
|
||||||
const process = spawn(__dirname + '/../lxc/execute', [
|
const process = spawn(__dirname + '/../lxc/execute', [
|
||||||
language.name,
|
language.name,
|
||||||
sourceFile,
|
sourceFile,
|
||||||
stdin ?? '',
|
stdin,
|
||||||
args?.join('\n') ?? '',
|
args.join('\n'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
|
|
Loading…
Reference in New Issue