Fork me on GitHub
#babashka
<
2022-03-05
>
jumar09:03:47

What's the best way to update a value in an EDN file with babashka? I have a figwheel-main.edn config which looks like this:

;; See 
;; and 


;; overriding default index.html page - we need to serve home.html from the server
{:open-url ":[[server-port]]/app" ;  ;; set target-dir different than "target" - see 
 :target-dir "resources"
 :css-dirs ["resources/public/css"] ; 
 :watch-dirs ["src/cljc" "src/cljs" "env/dev/cljs"] ; 
...
}
I need to parse port value from another edn file and replace [[server-port]] in figwheel-main.edn with this value. Ideally, I want to preserve all the comments and whitespaces. Should I just use sed ? 🙂

oxalorg (Mitesh)12:03:20

But for such a simple usecase just use str/replace and bit of regex!

borkdude09:03:41

or just slurp, str/replace + spit

jumar09:03:28

Perfect, thanks!