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

View File

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