fix hs
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const request = require("request")
|
||||
const rp = require("request-promise")
|
||||
, fs = require("fs");
|
||||
|
||||
const maxoutput = 500;
|
||||
@@ -13,7 +13,6 @@ const hsimports = [
|
||||
].map(imp => { return `import qualified ${imp}`; }).join("\r\n");
|
||||
|
||||
function sandbox(lang, code) {
|
||||
console.log(`${ __dirname }/../../../../neofetch`);
|
||||
const langs = {
|
||||
cpp: {
|
||||
"LanguageChoice": "7",
|
||||
@@ -23,13 +22,13 @@ function sandbox(lang, code) {
|
||||
},
|
||||
hs: {
|
||||
"LanguageChoice": "11",
|
||||
"Program": `${hsimports}\r\nmain = print(${code})`,
|
||||
"Program": `${hsimports}\r\nmain = ${code}`,
|
||||
"Input": "",
|
||||
"CompilerArgs": "-XUnicodeSyntax -XPartialTypeSignatures -o a.out source_file.hs"
|
||||
},
|
||||
py: {
|
||||
"LanguageChoice": "24",
|
||||
"Program": "print(" + code + ")",
|
||||
"Program": code,
|
||||
"Input": "",
|
||||
"CompilerArgs": "-o a.out source_file.hs"
|
||||
},
|
||||
@@ -67,9 +66,7 @@ function sandbox(lang, code) {
|
||||
json: true
|
||||
};
|
||||
|
||||
request(options, (err, res, body) => {
|
||||
if (err)
|
||||
return reject("Error!");
|
||||
rp(options).then(body => {
|
||||
if (body.Errors) {
|
||||
if (body.Errors.length > maxoutput)
|
||||
return reject(`holy fuck, Error wäre viel zu lang! (${body.Errors.length} Zeichen :DDDDDD)`)
|
||||
@@ -82,7 +79,10 @@ function sandbox(lang, code) {
|
||||
if (body.Result.length === 0)
|
||||
return reject("lol keine Ausgabe");
|
||||
resolve(body.Result);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
reject("Error!");
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
@@ -98,4 +98,4 @@ function bfgen(text) {
|
||||
return out;
|
||||
}
|
||||
|
||||
export { maxoutput, sandbox, bfgen };
|
||||
export { maxoutput, sandbox, bfgen, hsimports };
|
Reference in New Issue
Block a user