meyvn.nrepl_middleware.persistence.clj Maven / Gradle / Ivy
The newest version!
(ns meyvn.nrepl-middleware.persistence
(:require [clojure.string :as str]
[clojure.java.io :as io]
[meyvn.nrepl-middleware.utils :refer [read-conf]]
[fipp.edn :refer [pprint] :rename {pprint fipp}]))
(defn write-conf [conf]
(with-open [writer (io/writer (io/file "deps.edn"))]
(binding [*out* writer]
(fipp conf))))
(defn write-dep [conf lib version]
(let [deps (:deps conf)]
(->> (assoc deps (symbol lib) {:mvn/version version})
(assoc conf :deps)
write-conf)))
(defn persist-lib [query]
(let [[lib version] (str/split query #" ")]
(cond
(not (.exists (io/file "deps.edn"))) "NOT FOUND"
(contains? (:deps (read-conf "deps.edn")) (symbol lib)) "NOTHING TO DO"
:else (let [conf (read-conf "deps.edn")]
(write-dep conf lib version)
"OK"))))
© 2015 - 2024 Weber Informatics LLC | Privacy Policy