diff --git a/backend/src/api.ts b/backend/src/api.ts index 4872cdf..8188d63 100644 --- a/backend/src/api.ts +++ b/backend/src/api.ts @@ -1,6 +1,7 @@ "use strict"; import * as fs from "fs"; +import * as mkdirp from "mkdirp"; import * as pty from "node-pty"; import { IPty } from "node-pty"; import * as path from "path"; @@ -104,6 +105,9 @@ export class Session { if (suffix) { code += suffix; } + if (main.includes("/")) { + await mkdirp(path.dirname(path.resolve(tmpdir, main))); + } await new Promise((resolve, reject) => fs.writeFile(path.resolve(tmpdir, main), code, (err) => { if (err) { diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 4061f60..bd5d926 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -156,6 +156,15 @@ require("/usr/lib/node_modules/coffeescript/repl").start() main: "main.exs", run: "iex main.exs", template: `IO.puts("Hello, world!") +`, + }, + elvish: { + name: "Elvish", + monacoLang: "plaintext", + repl: "SHELL=/usr/bin/elvish HOME=. elvish", + main: ".elvish/rc.elv", + run: "SHELL=/usr/bin/elvish HOME=. elvish", + template: `echo "Hello, world!" `, }, emacs: { @@ -186,7 +195,7 @@ main() -> monacoLang: "plaintext", repl: "SHELL=/usr/bin/fish fish", main: "main.fish", - run: 'fish -C "$(< main.fish)"', + run: 'SHELL=/usr/bin/fish fish -C "$(< main.fish)"', template: `echo "Hello, world!" `, }, @@ -197,6 +206,17 @@ main() -> main: "main.fs", run: "gforth main.fs", template: `." Hello, world!" CR +`, + }, + fortran: { + name: "FORTRAN", + monacoLang: "plaintext", + main: "main.f", + compile: "flang main.f -o main", + run: "./main", + template: ` program hello + print *, "Hello, world!" + end program hello `, }, fsharp: { @@ -265,6 +285,15 @@ main = putStrLn "Hello, world!" main: "main.kts", run: "kotlinc -script main.kts; kotlinc", template: `println("Hello, world!") +`, + }, + ksh: { + name: "Ksh", + monacoLang: "shell", + repl: "SHELL=/usr/bin/ksh HOME=. ksh", + main: ".kshrc", + run: "SHELL=/usr/bin/ksh HOME=. ksh", + template: `echo "Hello, world!" `, }, lolcode: { @@ -305,6 +334,32 @@ eval.apply(this, [require("fs").readFileSync("main.js", {encoding: "utf-8"})]) require("repl").start() '`, template: `console.log("Hello, world!") +`, + }, + objectivec: { + name: "Objective-C", + monacoLang: "objective-c", + main: "main.m", + compile: + "gcc $(gnustep-config --objc-flags) main.m $(gnustep-config --base-libs) -o main", + run: "./main", + template: `#import + +int main() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSLog(@"Hello, world!"); + [pool drain]; + return 0; +} +`, + }, + perl: { + name: "Perl", + monacoLang: "perl", + repl: "re.pl", + main: "main.pl", + run: "re.pl --rcfile ./main.pl", + template: `print("Hello, world!\\n") `, }, php: { @@ -316,6 +371,15 @@ require("repl").start() template: `