Created
June 28, 2020 23:49
-
-
Save samedhi/7d3071e54f5a6768be4b7fae3cb951f9 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
#!/usr/bin/env bb | |
;; --- CONSTANTS -- | |
(def projects-directory "/home/samedhi/") | |
(def commit-to-video-config-filename ".commit-to-video.edn") | |
;; -- FILESYSTEM -- | |
(defn list-dir | |
"Get a sequence of files under 'directory as Java File objects" | |
[directory] | |
(-> directory | |
io/file | |
.listFiles | |
seq)) | |
(defn absolute? [file] | |
(.isAbsolute file)) | |
(defn directory? [file] | |
(.isDirectory file)) | |
(defn exist? [file] | |
(.exists file)) | |
(defn git-directory? [file] | |
(exist? (io/file file ".git"))) | |
(defn contains-config? [file] | |
(exist? (io/file file commit-to-video-config-filename))) | |
(defn path->file [path file] | |
(if (absolute? (io/file path)) | |
(io/file path) | |
(io/file file path))) | |
(defn read-config [file] | |
(-> (io/file file commit-to-video-config-filename) | |
slurp | |
edn/read-string | |
(update :videos-path path->file file) | |
(assoc :git-path file))) | |
(defn videos-exist? [config] | |
(let [{:keys [videos-path]} config] | |
(and (exist? videos-path) | |
(directory? videos-path)))) | |
(->> (list-dir projects-directory) | |
(filter directory?) | |
(filter git-directory?) | |
(filter contains-config?) | |
(map read-config) | |
(filter videos-exist?)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment