Created
August 8, 2016 21:24
-
-
Save stephenbrady/400989c9cf1f2283f61ed08049c9bd2a to your computer and use it in GitHub Desktop.
Exposing boot file watching
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
(def FileChangeCallbacks (atom [])) | |
(defn on-file-changes | |
[changes] | |
(sync-user-dirs!) | |
(doseq [callback (seq @FileChangeCallbacks)] | |
(try (callback changes) | |
(catch Throwable t | |
(println "Exception in boot watch callback: " t)))) | |
(reset! last-file-change (System/currentTimeMillis))) | |
(defn set-user-dirs-with-callback! [] | |
(@src-watcher) | |
(let [debounce (or (get-env :watcher-debounce) 10) | |
env-keys [:source-paths :resource-paths :asset-paths :checkout-paths] | |
dir-paths (set (->> (mapcat get-env env-keys) | |
(filter #(.isDirectory (io/file %))))) | |
watcher (watch-dirs on-file-changes dir-paths :debounce debounce)] | |
(reset! src-watcher watcher) | |
(set-fake-class-path!) | |
(sync-user-dirs!))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment