Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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))))
@ghost

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.