Fork me on GitHub
#nrepl
<
2020-12-02
>
David Pham11:12:11

Hello everyone 馃檪 I wonder if it was possible when using the cli command to evaluate code in the nrepl server? I would like to run the djblue/portal commands on start.

flowthing11:12:16

Not sure, I don't think so, but one option would be to do something like this:

位 cat deps.edn
{:deps {nrepl/nrepl {:mvn/version "0.8.3"}
        djblue/portal {:mvn/version "0.6.4"}}}
位 cat src/user.clj
(ns user
  (:require [portal.api :as p]))

(p/open)
(p/tap)
位 clojure -M -m nrepl.cmdline
nREPL server started on port 61861 on host localhost - 

馃挴 3
flowthing11:12:01

Or https://github.com/gfredericks/user.clj if you don't want to do it per-project.

flowthing11:12:05

(I would probably have a function in user.clj that calls p/open and p/tap instead of calling them on the top level, but YMMV.)

David Pham11:12:23

I wish we could have cljc though 馃檪

鈽濓笍 3
djblue20:12:34

You can also add (.addShutdownHook (Runtime/getRuntime) (Thread. #(p/close))) to user.clj for cleanup