Created
December 24, 2013 21:27
-
-
Save JulianBirch/8117925 to your computer and use it in GitHub Desktop.
lessc watcher in Clojure
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
(ns lessc | |
(:require [pro.juxt.dirwatch :refer (watch-dir)] | |
[clojure.java.io :refer (file)] | |
[spyscope.core] | |
[clojure.core.async :as a])) | |
(defn run-less [] | |
(println "Running LESS") | |
(doto | |
(ProcessBuilder. ["lessc" "resources/bootstrap/assets/mybootstrap.less" "resources/public/s.css"]) | |
(.redirectOutput java.lang.ProcessBuilder$Redirect/INHERIT) | |
(-> .start .waitFor)) | |
(println "Finishing LESS")) | |
(defn process-watch [c] | |
(println "Starting") | |
(run-less) | |
(loop [] | |
(a/<!! c) | |
(println "Files Changed") | |
(run-less) | |
(recur))) | |
(defn watch [] | |
(let [c (a/chan (a/dropping-buffer 1)) | |
f (file "/home/julian/handel/resources/bootstrap/assets/")] | |
(watch-dir #(a/>!! c %) f) | |
(future (process-watch c)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! Otherwise I never would have found out there should be $ in between ProcessBuilder.Redirect.