diff --git a/backend/src/api.ts b/backend/src/api.ts index a527732..dece1ea 100644 --- a/backend/src/api.ts +++ b/backend/src/api.ts @@ -66,7 +66,7 @@ export class Session { } }; run = async () => { - const { repl, file, run } = this.config; + const { repl, file, suffix, run } = this.config; if (this.term) { this.term.kill(); } @@ -82,8 +82,12 @@ export class Session { ); let cmdline: string[]; if (this.code || !repl) { + let code = this.code; + if (suffix) { + code += suffix; + } await new Promise((resolve, reject) => - fs.writeFile(path.resolve(tmpdir, file), this.code, (err) => { + fs.writeFile(path.resolve(tmpdir, file), code, (err) => { if (err) { reject(err); } else { diff --git a/backend/src/langs.ts b/backend/src/langs.ts index 856dc5b..3978b15 100644 --- a/backend/src/langs.ts +++ b/backend/src/langs.ts @@ -1,6 +1,8 @@ export interface LangConfig { repl?: string[]; file?: string; + prefix?: string; + suffix?: string; run?: string[] | string; monacoLang: string; name: string; @@ -65,7 +67,8 @@ export const langs = { nodejs: { repl: ["node"], file: "main.js", - run: 'node -i -e "$(< main.js)"', + suffix: '\n;require("repl").start();', + run: "node main.js", name: "Node.js", monacoLang: "javascript", }, diff --git a/scripts/docker-install.bash b/scripts/docker-install.bash index 96810f8..91b60ba 100755 --- a/scripts/docker-install.bash +++ b/scripts/docker-install.bash @@ -12,13 +12,16 @@ uid="$1" export DEBIAN_FRONTEND=noninteractive apt-get update -apt-get install -y curl gnupg +apt-get install -y curl gnupg lsb-release rm -rf /var/lib/apt/lists/* curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - +curl -sS https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - -tee -a /etc/apt/sources.list.d/yarn.list >/dev/null <<"EOF" +tee -a /etc/apt/sources.list.d/custom.list >/dev/null <<"EOF" +deb https://deb.nodesource.com/node_14.x focal main deb https://dl.yarnpkg.com/debian/ stable main +deb-src https://deb.nodesource.com/node_14.x EOF packages="