Make ran field do something

This commit is contained in:
Vrganj 2021-01-16 14:19:29 +01:00
parent f685bdc751
commit 8fd831982e
2 changed files with 9 additions and 4 deletions

View File

@ -49,10 +49,10 @@ app.post(
language.aliases.includes(req.body.language.toLowerCase()) language.aliases.includes(req.body.language.toLowerCase())
); );
const { stdout, stderr, output } = await execute(language, req.body.source, req.body.args); const { stdout, stderr, output, ran } = await execute(language, req.body.source, req.body.args);
res.status(200).json({ res.status(200).json({
ran: true, ran,
language: language.name, language: language.name,
version: language.version, version: language.version,
stdout, stdout,

View File

@ -28,12 +28,17 @@ function execute(language, source, args) {
output += chunk; output += chunk;
}); });
process.on('exit', () => { process.on('exit', code => {
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);
resolve({ stdout, stderr, output }); resolve({
stdout,
stderr,
output,
ran: code === 0,
});
}); });
}); });
} }