Skip to content

Instantly share code, notes, and snippets.

@stephenbrady
Created August 8, 2016 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenbrady/400989c9cf1f2283f61ed08049c9bd2a to your computer and use it in GitHub Desktop.
Save stephenbrady/400989c9cf1f2283f61ed08049c9bd2a to your computer and use it in GitHub Desktop.
Exposing boot file watching
(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