From b1ecae7841045b3bf32e86211f321c133d66dcd5 Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Fri, 15 Mar 2019 20:24:49 -0400 Subject: [PATCH] Add Julia --- README.md | 2 ++ docker/julia/Dockerfile | 4 ++++ docker/julia/run.sh | 5 +++++ src/languages/julia.js | 22 ++++++++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 docker/julia/Dockerfile create mode 100644 docker/julia/run.sh create mode 100644 src/languages/julia.js diff --git a/README.md b/README.md index 8bc534b..e3eea20 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,8 @@ Options are optionally set in `options`, which is a semicolon-delimited list of - `js` JavaScript (Node 11.11.0) - `harmony` enables harmony features (`--harmony` on node) - `e` prints the result of evaluating the code +- `julia` Julia (Julia 1.1.0) + - `e` prints the result of evaluating the code - `pas` Pascal (FPC 3.0.4) - `php` PHP (PHP 7.3.3) - `pl` Perl (Perl 5.28.1) diff --git a/docker/julia/Dockerfile b/docker/julia/Dockerfile new file mode 100644 index 0000000..b81a6c8 --- /dev/null +++ b/docker/julia/Dockerfile @@ -0,0 +1,4 @@ +FROM julia +LABEL author="1Computer1" + +COPY run.sh /var/run/ diff --git a/docker/julia/run.sh b/docker/julia/run.sh new file mode 100644 index 0000000..5b134b1 --- /dev/null +++ b/docker/julia/run.sh @@ -0,0 +1,5 @@ +if [ "$EVAL_EXPR" = "true" ]; then + julia -E "$1" +else + julia -e "$1" +fi diff --git a/src/languages/julia.js b/src/languages/julia.js new file mode 100644 index 0000000..fc26a1d --- /dev/null +++ b/src/languages/julia.js @@ -0,0 +1,22 @@ +const Language = require('../struct/Language'); + +class Julia extends Language { + constructor() { + super('julia', { + aliases: ['julia'], + options: { + e: () => '' + } + }); + } + + runWith(options) { + if (options.has('e')) { + return { id: this.id, env: { EVAL_EXPR: 'true' } }; + } + + return super.runWith(options); + } +} + +module.exports = Julia;