Skip to content

Instantly share code, notes, and snippets.

@JulianBirch
Created December 24, 2013 21:27
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 JulianBirch/8117925 to your computer and use it in GitHub Desktop.
Save JulianBirch/8117925 to your computer and use it in GitHub Desktop.
lessc watcher in Clojure
(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))))
Copy link

ghost commented Jul 5, 2014

Thanks! Otherwise I never would have found out there should be $ in between ProcessBuilder.Redirect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment