Improve createEmpty, add setup

This commit is contained in:
Radon Rosborough 2020-07-12 14:18:07 -06:00
parent 03117016cd
commit 3fafd3422f
2 changed files with 13 additions and 9 deletions

View File

@ -87,6 +87,9 @@ export class Session {
this.uidInfo = { uid, returnUID }; this.uidInfo = { uid, returnUID };
this.log(`Borrowed uid ${this.uid}`); this.log(`Borrowed uid ${this.uid}`);
await this.run(this.privilegedSetup()); await this.run(this.privilegedSetup());
if (this.config.setup) {
await this.run(this.privilegedSpawn(bash(this.config.setup)));
}
await this.runCode(); await this.runCode();
if (this.config.daemon) { if (this.config.daemon) {
const daemonArgs = this.privilegedSpawn(bash(this.config.daemon)); const daemonArgs = this.privilegedSpawn(bash(this.config.daemon));
@ -285,7 +288,7 @@ export class Session {
cmdline = `echo '${name} has no REPL, press Run to see it in action'`; cmdline = `echo '${name} has no REPL, press Run to see it in action'`;
} }
if (code === undefined) { if (code === undefined) {
code = createEmpty ? "" : template; code = createEmpty !== undefined ? createEmpty : template;
} }
if (code && suffix) { if (code && suffix) {
code += suffix; code += suffix;

View File

@ -3,11 +3,12 @@ export interface LangConfig {
name: string; name: string;
monacoLang: string; monacoLang: string;
daemon?: string; daemon?: string;
setup?: string;
repl?: string; repl?: string;
main: string; main: string;
prefix?: string; prefix?: string;
suffix?: string; suffix?: string;
createEmpty?: boolean; createEmpty?: string;
compile?: string; compile?: string;
run: string; run: string;
lspSetup?: string; lspSetup?: string;
@ -385,7 +386,7 @@ output = "Hello, world!"
monacoLang: "plaintext", monacoLang: "plaintext",
repl: `SHELL=/usr/bin/elvish HOME="$PWD" elvish`, repl: `SHELL=/usr/bin/elvish HOME="$PWD" elvish`,
main: ".elvish/rc.elv", main: ".elvish/rc.elv",
createEmpty: true, createEmpty: ``,
run: `SHELL=/usr/bin/elvish HOME="$PWD" elvish`, run: `SHELL=/usr/bin/elvish HOME="$PWD" elvish`,
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,
@ -422,7 +423,7 @@ main() ->
monacoLang: "plaintext", monacoLang: "plaintext",
repl: "factor-lang", repl: "factor-lang",
main: ".factor-rc", main: ".factor-rc",
createEmpty: true, createEmpty: ``,
run: "factor-lang", run: "factor-lang",
template: `USE: io template: `USE: io
@ -628,7 +629,7 @@ PLEASE GIVE UP
monacoLang: "shell", monacoLang: "shell",
repl: `SHELL=/usr/bin/ksh HOME="$PWD" ksh`, repl: `SHELL=/usr/bin/ksh HOME="$PWD" ksh`,
main: ".kshrc", main: ".kshrc",
createEmpty: true, createEmpty: ``,
run: `SHELL=/usr/bin/ksh HOME="$PWD" ksh`, run: `SHELL=/usr/bin/ksh HOME="$PWD" ksh`,
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,
@ -1103,7 +1104,7 @@ binding_irb.run(IRB.conf)
monacoLang: "shell", monacoLang: "shell",
repl: `SHELL=/usr/bin/sh HOME="$PWD" posh -l`, repl: `SHELL=/usr/bin/sh HOME="$PWD" posh -l`,
main: ".profile", main: ".profile",
createEmpty: true, createEmpty: ``,
run: `SHELL=/usr/bin/sh HOME="$PWD" posh -l`, run: `SHELL=/usr/bin/sh HOME="$PWD" posh -l`,
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,
@ -1265,7 +1266,7 @@ END
monacoLang: "tcl", monacoLang: "tcl",
repl: "tclsh", repl: "tclsh",
main: ".tclshrc", main: ".tclshrc",
createEmpty: true, createEmpty: ``,
run: `HOME="$PWD" tclsh`, run: `HOME="$PWD" tclsh`,
template: `puts {Hello, world!} template: `puts {Hello, world!}
`, `,
@ -1276,7 +1277,7 @@ END
monacoLang: "shell", monacoLang: "shell",
repl: `SHELL=/usr/bin/tcsh HOME="$PWD" tcsh`, repl: `SHELL=/usr/bin/tcsh HOME="$PWD" tcsh`,
main: ".tcshrc", main: ".tcshrc",
createEmpty: true, createEmpty: ``,
run: `SHELL=/usr/bin/tcsh HOME="$PWD" tcsh`, run: `SHELL=/usr/bin/tcsh HOME="$PWD" tcsh`,
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,
@ -1449,7 +1450,7 @@ message:
monacoLang: "shell", monacoLang: "shell",
repl: "SHELL=/usr/bin/zsh zsh", repl: "SHELL=/usr/bin/zsh zsh",
main: ".zshrc", main: ".zshrc",
createEmpty: true, createEmpty: ``,
run: `SHELL=/usr/bin/zsh ZDOTDIR="$PWD" zsh`, run: `SHELL=/usr/bin/zsh ZDOTDIR="$PWD" zsh`,
template: `echo "Hello, world!" template: `echo "Hello, world!"
`, `,