This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-27
Channels
- # adventofcode (7)
- # announcements (31)
- # babashka (15)
- # beginners (14)
- # calva (45)
- # circleci (6)
- # clojure (27)
- # clojure-europe (19)
- # clojure-france (2)
- # clojure-gamedev (4)
- # clojure-uk (2)
- # clojurescript (26)
- # conjure (14)
- # data-science (6)
- # deps-new (7)
- # depstar (4)
- # emacs (13)
- # events (1)
- # fulcro (20)
- # graalvm (2)
- # hoplon (30)
- # joker (11)
- # london-clojurians (1)
- # malli (26)
- # pathom (2)
- # re-frame (13)
- # reagent (8)
- # reclojure (3)
- # reveal (8)
- # robots (4)
- # shadow-cljs (29)
- # sql (5)
- # tools-deps (28)
- # vim (4)
Curious, can one configure clj
to run some code as soon as a REPL is fired up?
Basically an equivalent to Lein's :init
option
clj -M -e '(some-code)' -r
Nice! Thanks to your answer I checked out https://github.com/practicalli/clojure-deps-edn/blob/65a48e1547d289a3d647d9f32bf3d2cc7fe8d5d3/deps.edn#L479 I wish though that those humongous strings could be expressed as nicely formatted sexprs instead
you can make a function for that somewhere in sourcepath
in one of my projects I have dev/src/dev/utils.clj
file with (ns dev.utils)
I also add :extra-paths ["dev/src"]
to one of my alias for dev environment
in that namespace you can create a function
and then from console run it using requiring-resolve
Ah nice! Similarly, my -e
could be a single require
and I do all the work in a proper .clj file
That way I'd skip the last step you describe
clj -A:dev -M -e '((requiring-resolve 'dev/init))' -r
that’s how it could look like in cli
Or use -i instead of -e
Oh sorry, slack didn’t show me the last message there :)
https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L93 shows how to load a dev.clj
script from from your .clojure
folder (I know this won't work with XDG systems) so you can have a dev script for all your projects, without needing code in every project.
(I should probably rename that so it doesn't conflict with any :dev
alias someone actually has in a project deps.edn
file)
@slack.jcpsantiago does deps.edn have version numbers?
@borkdude Mine straight from clj-new
doesn’t and it seems it’s not supposed to? There is a version in pom.xml
<version>0.1.0-SNAPSHOT</version>
, so I could read this file. I was looking for something that would work like environ
and would read this automatically
@slack.jcpsantiago if using environ the set an Environment variable or create a .properties file for a Java system property
I just inspected clojure.basis to see if my jvm-opts propagated correctly when composing aliases. It did. Neat.
Btw, I stumbled upon this blog https://insideclojure.org/2020/07/28/clj-exec/ but it seems the arguments have been renamed from :fn
and :args
to :exec-fn
and :exec-args
?
That name change was covered in https://insideclojure.org/2020/09/04/clj-exec/
That blog is a great example of the history of Clojure features and how they evolve during prerelease work. Changing past posts would remove that evolution.
“Don’t believe everything you read on the internet” - Lincoln
It would make sense to add a footnote to an older blog post with a reference to a later update, if one was so inclined.
Well, I’m on vacation :)
Sorry, I should have mentioned that I'm not trying to nudge you or anyone to do that. I do agree that leaving older posts unchanged (except perhaps by addition of such forward-reference footnotes) makes a lot of sense, for anyone wanting to see the history.
https://github.com/seancorfield/dot-clojure/blob/develop/deps.edn#L93 shows how to load a dev.clj
script from from your .clojure
folder (I know this won't work with XDG systems) so you can have a dev script for all your projects, without needing code in every project.