Fork me on GitHub
#babashka
<
2021-02-07
>
borkdude15:02:48

^ fun lein imitation script based on deps.edn

lvh16:02:09

klein 😂

👍 3
Eccentric J20:02:00

I am writing a script that is intending to process multiple project’s deps.edn, install the deps, and generate the classpath. Ideally I would to use babashka.deps or babashka.clojure but how would I isolate them? How would I run it in such a way where .cpcache and such are generated according to the project’s respective directory?

borkdude20:02:22

@jayzawrotny You mean something like babashka.deps/add-deps but call it multiple times and get only the resulting classpath for each file?

Eccentric J20:02:48

Now that I think about it I don’t think babashka.deps or babashka.clojure is the best tool for the job on this one. Perhaps I’m better off shelling out to bb --clojure to process those deps as a separate process in their respective project directories?

borkdude20:02:51

Calling add-deps does what it says: it only adds deps to the classpath, it doesn't replace the previous classpath. However, you can hack around this by storing the previous classpath and use str/replace to remove it from the next one. This is relying on the impl detail that the classpath is only concatenated currently and there is no de-duplication whatsoever.

borkdude20:02:52

yeah, you can shell out using babashka.process or clojure.java.shell and set the :dir argument to start the processes from a different dir

borkdude20:02:34

I think that would be the most reliable

Eccentric J20:02:54

And if I combine that with the --clojure flag it should work on windows?

borkdude20:02:01

yes, it should

borkdude20:02:19

this is one of the reasons I included this, since clojure on Windows is a bit messy with powershell and shelling out and such

Eccentric J20:02:32

The fs package came at a perfect time too, I didn’t even think about how platform specific my path separators were 😅