Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Commit

Permalink
Execute *main-cli-fn* if set and no -m (fixes #235)
Browse files Browse the repository at this point in the history
  • Loading branch information
arichiardi committed Aug 22, 2017
1 parent ad5a87d commit 9e83cde
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cljs/snapshot/lumo/repl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
11 changes: 11 additions & 0 deletions src/js/cljs.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,17 @@ async function startClojureScriptEngine(opts: CLIOptsType): Promise<mixed> {

startREPL(opts);
}

if (!mainNsName && !repl) {
initClojureScriptEngine(opts);
execute(
"(require 'lumo.repl) (lumo.repl/run-main-cli-fn)",
'text',
true,
false,
0,
);
}
}

export default startClojureScriptEngine;

0 comments on commit 9e83cde

Please sign in to comment.