This commit is contained in:
Vrganj 2021-01-15 20:40:18 +01:00
parent 3f301b8c1f
commit 6fdf2d6061
3 changed files with 20 additions and 29 deletions

View File

@ -4,47 +4,41 @@ const app = express();
const languages = require('./languages'); const languages = require('./languages');
const { spawn } = require('child_process'); const { spawn } = require('child_process');
(function setVersions() { {
let output = '';
const process = spawn(__dirname + '/../../lxc/versions'); const process = spawn(__dirname + '/../../lxc/versions');
process.stdout.setEncoding('utf-8'); let output = '';
process.stderr.setEncoding('utf-8'); process.stderr.on('data', chunk => output += chunk);
process.stdout.on('data', chunk => output += chunk);
process.stdout.addListener('data', chunk => {
output += chunk;
});
process.stderr.addListener('data', chunk => {
output += chunk;
});
process.on('exit', () => { process.on('exit', () => {
const sections = output.toLowerCase().split('---'); const sections = output.toLowerCase().split('---');
const versions = {}; const versions = {};
for (let section of sections) { for (const section of sections) {
section = section.trim().split('\n'); const lines = section.trim().split('\n');
if (section.length >= 2) { if (lines.length >= 2) {
const language = section[0]; const language = lines[0];
console.log(language);
if (language === 'java') { if (language === 'java') {
versions[language] = /\d+/.exec(section[2]); versions[language] = /\d+/.exec(lines[1])?.[0];
} else if (language === 'emacs') { } else if (language === 'emacs') {
versions[language] = /\d+\.\d+/.exec(section[2]); versions[language] = /\d+\.\d+/.exec(lines[1])?.[0];
} else { } else {
versions[language] = /\d\.\d\.\d/.exec(section.slice(1).join('\n'))?.[0]; versions[language] = /\d+\.\d+\.\d+/.exec(section)?.[0];
} }
} }
} }
for (const language of languages) { for (const language of languages) {
console.log(language.name, versions[language.name])
language.version = versions[language.name]; language.version = versions[language.name];
} }
}); });
})(); }
app.use(express.json()); app.use(express.json());
@ -94,9 +88,6 @@ async function launch(res, language, body) {
if (language.version) if (language.version)
result.version = language.version; result.version = language.version;
process.stderr.setEncoding('utf-8');
process.stdout.setEncoding('utf-8');
process.stderr.addListener('data', chunk => { process.stderr.addListener('data', chunk => {
result.stderr += chunk; result.stderr += chunk;
result.output += chunk; result.output += chunk;

View File

@ -60,7 +60,7 @@ module.exports = [
aliases: ['java'], aliases: ['java'],
}, },
{ {
name: 'javascript', name: 'node',
aliases: ['javascript', 'js', 'node'], aliases: ['javascript', 'js', 'node'],
}, },
{ {
@ -99,10 +99,6 @@ module.exports = [
name: 'python2', name: 'python2',
aliases: ['python2'], aliases: ['python2'],
}, },
{
name: 'r',
aliases: ['r'],
},
{ {
name: 'rust', name: 'rust',
aliases: ['rs', 'rust'], aliases: ['rs', 'rust'],

View File

@ -69,6 +69,10 @@ echo 'nasm'
lxc-attach --clear-env -n piston -- /bin/bash -l -c "nasm -version" lxc-attach --clear-env -n piston -- /bin/bash -l -c "nasm -version"
echo '---' echo '---'
echo 'nasm64'
lxc-attach --clear-env -n piston -- /bin/bash -l -c "nasm -version"
echo '---'
echo 'node' echo 'node'
lxc-attach --clear-env -n piston -- /bin/bash -l -c "node --version" lxc-attach --clear-env -n piston -- /bin/bash -l -c "node --version"
echo '---' echo '---'