meyvn.nrepl_middleware.local_root.clj Maven / Gradle / Ivy
The newest version!
(ns meyvn.nrepl-middleware.local-root
(:require
[meyvn.nrepl-middleware.utils :refer [read-conf]]
[clojure.tools.deps :as deps]
[watch.man :refer [watch!]]
[clojure.java.io :as io]
[clojure.tools.logging :as log]))
(defn local-roots
([]
(local-roots "deps.edn"))
([deps]
(let [conf (read-conf deps)
paths (->> (for [[_ v] (:deps conf)]
(select-keys v [:local/root]))
(filter (comp not empty?)))]
(map :local/root paths))))
(defn paths []
(flatten (for [dir (local-roots)
paths (:paths (-> (deps/find-edn-maps (str dir "/deps.edn"))
vals
deps/merge-edns))]
(filter #(.isDirectory %) (file-seq (io/file (str dir "/" paths)))))))
(defn start-watching []
(doseq [dir (paths)]
(log/info "Watching " (str dir))
(watch! (str dir) (fn [event] (let [type (first (:types event))]
(when (and (= :modify type) (:type event :path))
(let [path (str dir "/" (:path event))]
(load-file path)
(log/debug "Loading" path))))))))
© 2015 - 2024 Weber Informatics LLC | Privacy Policy