Fork me on GitHub
#leiningen
<
2021-11-22
>
frozenlock20:11:41

Is there a way to retrieve data from somewhere in project.clj and put in :aliases? For example, I'd like to configure :figwheel-main in some profiles and then be able to pass those configs to the figwheel launch command in :aliases.

vemv20:11:35

I don't get what you want exactly, can you rephrase it? (perhaps without mentioning figwheel)

frozenlock20:11:24

Sure:

{:profiles {:A {:compiler :config-map}}

 :aliases ["with-profiles" "A" "run" "m" "something.main" "-co"
           #=(pr-str ***COMPILER***)]}
I'd like to fill ***COMPILER*** with the data from :compiler as defined in the profile.

vemv21:11:02

(def data {:compiler :config-map})

(defproject foo :profiles {:A ~data})

vemv21:11:22

before defproject you can def/defns, without any special syntax required

vemv21:11:49

inside defproject you can use ~ to eval arbitrary expressions, within which you can refer to any prior def/defns

frozenlock21:11:49

Right, but then I can't extract the merged profiles, can I?

👀 1
vemv21:11:40

if you don't want pure data but the result of a Lein computation, that sounds like something that plugins/middleware can do

frozenlock21:11:58

I was afraid of that 🙃

vemv21:11:19

here is an example of a piece of 'inline middleware', no messing with .jars required https://github.com/nedap/formatting-stack/blob/31a17527260899b5a052e7e8fc8c4aaf37609d32/project.clj#L84-L101

vemv21:11:44

the fn receives a project map as an argument from Lein, probably with all profiles merged?

frozenlock21:11:03

Oh an inline middleware, that's very interesting

frozenlock21:11:19

I'll explore this path, thank you very much!

🍻 1