From 9e83cde5dbd379b976a325277097f8dc16840764 Mon Sep 17 00:00:00 2001 From: Andrea Richiardi Date: Tue, 22 Aug 2017 09:36:19 -0700 Subject: [PATCH] Execute *main-cli-fn* if set and no -m (fixes #235) --- src/cljs/snapshot/lumo/repl.cljs | 5 +++++ src/js/cljs.js | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/cljs/snapshot/lumo/repl.cljs b/src/cljs/snapshot/lumo/repl.cljs index 7705250b..74cbe39b 100644 --- a/src/cljs/snapshot/lumo/repl.cljs +++ b/src/cljs/snapshot/lumo/repl.cljs @@ -1149,6 +1149,11 @@ (handle-error e true))))))))) nil)) +(defn- ^:export run-main-cli-fn + [] + (when (fn? *main-cli-fn*) + (apply *main-cli-fn* *command-line-args*))) + (defn- ^:export get-current-ns [session-id] (let [{:keys [ns]} (get @session-states session-id @default-session-state)] (str ns))) diff --git a/src/js/cljs.js b/src/js/cljs.js index f0026a99..e88aa64f 100644 --- a/src/js/cljs.js +++ b/src/js/cljs.js @@ -460,6 +460,17 @@ async function startClojureScriptEngine(opts: CLIOptsType): Promise { startREPL(opts); } + + if (!mainNsName && !repl) { + initClojureScriptEngine(opts); + execute( + "(require 'lumo.repl) (lumo.repl/run-main-cli-fn)", + 'text', + true, + false, + 0, + ); + } } export default startClojureScriptEngine;