Clojure test code

Clojure code posted by Vic
created at 26 Feb 17:59

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(defn sync-lib-deps [& {:as opts}]
  (->> (for [lib  (if (seq (:libs opts))
                    (set/intersection (set enabled-libs) (set (:libs opts)))
                    enabled-libs)
             path (fs/glob (str "libs/" lib) "deps.edn")
             :let [f (io/file (str path))]]
         (do
           (when-not (.exists (io/file f))
             (println "File does not exist" f)
             (System/exit 1))
           (let [original (slurp f)
                 updated (str (replace-dependencies original dependencies))]
             (when (not= original updated)
               (spit f updated))
             (str path))))
       (remove nil?)
       doall))

(defn -main [& _]
  (sync-lib-deps))

(when (= *file* (System/getProperty "babashka.file"))
  (apply -main *command-line-args*))

(comment
  (def test-code
    "{:paths [\"src\"]
 :deps  {integrant/integrant       {:mvn/version \"0.7.0\"}
         com.xtdb/xtdb-core        {:mvn/version \"1.20.0\"}}}")

  (replace-dependencies test-code dependencies))
1.03 KB in 5 ms with coderay