Created
June 19, 2019 02:54
-
-
Save minikomi/17b3fd768e08c91909d6123b42c3e0ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn get-dep-graph [src-paths] | |
(let [src-files | |
(apply set/union | |
(map (comp #(ns-find/find-clojure-sources-in-dir %) | |
io/file) | |
src-paths)) | |
tracker (ns-file/add-files {} src-files) | |
dep-graph (tracker ::ns-track/deps)] | |
dep-graph)) | |
(defn get-dep-tree [] | |
(let [ds (get-dep-graph) | |
edges (for [[d ds2] (:dependents ds) | |
d2 ds2] | |
[d d2]) | |
roots (set/difference (set (keys (:dependencies ds))) | |
(set (keys (:dependents ds)))) | |
subtrees (reduce | |
(fn [acc [c p]] | |
(update acc p assoc c (get acc c {}))) | |
{} | |
edges)] | |
(select-keys subtrees roots))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment