You can run many languages now

This commit is contained in:
Radon Rosborough 2020-06-07 15:36:07 -06:00
parent f4178588b7
commit d5430812bc
2 changed files with 18 additions and 3 deletions

View File

@ -58,6 +58,13 @@ export class Session {
break;
}
};
parseCmdline = (cmdline: string[] | string) => {
if (typeof cmdline === "string") {
return ["bash", "-c", cmdline];
} else {
return cmdline;
}
};
run = async () => {
const { repl, file, run } = this.config;
if (this.term) {
@ -84,9 +91,9 @@ export class Session {
}
})
);
cmdline = run;
cmdline = this.parseCmdline(run);
} else {
cmdline = repl;
cmdline = this.parseCmdline(repl);
}
this.term = pty.spawn(cmdline[0], cmdline.slice(1), {
name: "xterm-color",

View File

@ -1,7 +1,7 @@
export interface LangConfig {
repl?: string[];
file?: string;
run?: string[];
run?: string[] | string;
monacoLang: string;
name: string;
}
@ -9,6 +9,8 @@ export interface LangConfig {
export const langs = {
bash: {
repl: ["bash"],
file: "main.bash",
run: ["bash", "--rcfile", "main.bash"],
name: "Bash",
monacoLang: "shell",
},
@ -41,6 +43,8 @@ export const langs = {
},
haskell: {
repl: ["ghci"],
file: "Main.hs",
run: ["ghci", "Main.hs"],
name: "Haskell",
monacoLang: "plaintext",
},
@ -60,6 +64,8 @@ export const langs = {
},
nodejs: {
repl: ["node"],
file: "main.js",
run: 'node -i -e "$(< main.js)"',
name: "Node.js",
monacoLang: "javascript",
},
@ -86,6 +92,8 @@ export const langs = {
},
zsh: {
repl: ["env", "SHELL=/usr/bin/zsh", "zsh"],
file: ".zshrc",
run: ["env", "ZDOTDIR=.", "zsh"],
name: "Zsh",
monacoLang: "shell",
},