Fork me on GitHub
#leiningen
<
2019-07-10
>
Stefano Bertoli17:07:42

Hi everyone, do someone knows if there is a way to pass data to a clojurescript project (Reagent) when building from leiningen?

Stefano Bertoli17:07:37

What I would like to do it get the last commit information from the git repo inside the clojurescript project, and pass that information to my project to be able to display it inside the build

Stefano Bertoli17:07:48

The more general question would be if there is a way to trigger some Clojure code when calling a build command like lein package

jvtrigueros19:07:47

Maybe there's a more straightforward answer to your questions, but I've used :filespecs to grab git information and package it during lein uberjar https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L432

jvtrigueros19:07:44

I'm not sure how a clojurescript build differs as filespecs is specifically for adding things to a jar file.

Stefano Bertoli19:07:37

Mmmmh thanks for the answer, I’ll check it out! 😃

mikerod20:07:40

@elkiwydev you can pass things to CLJS via :closure-defines

mikerod20:07:51

this may be reasonable for some usages

mikerod20:07:54

within a :cljsbuild in lein project:

:closure-defines  {your.project.ns.name.SOME_DEF ~(find-some-dynamic-build-info)}

mikerod20:07:25

And you could do a

(defn find-some-dynamic-build-info []
 ;; lookup things here )
in top of project.clj above the defproject declaration

mikerod20:07:46

which in this case, looks like you’d probably be shelling out to git

mikerod20:07:02

but it’s pretty open with what you want to do to get whatever information

Stefano Bertoli20:07:36

Thanks @mikerod, I’ll look for that too!

👍 4