Skip to content

Commit

Permalink
support multiple output files, closes #8
Browse files Browse the repository at this point in the history
make garden pod pool global to avoid StreamClosed exception:
boot-clj/boot#270
  • Loading branch information
esp1 authored and martinklepsch committed Aug 11, 2015
1 parent 13e44a1 commit 1c0264f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.boot
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

(require '[adzerk.bootlaces :refer [bootlaces! build-jar push-release]])

(def +version+ "1.2.5-6")
(def +version+ "1.2.5-7")

(bootlaces! +version+)

Expand Down
30 changes: 15 additions & 15 deletions src/org/martinklepsch/boot_garden.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
[boot.file :as file]
[boot.util :as util]))

(def initial
(atom true))
(def processed
(atom #{}))

(defn add-dep [env dep]
(update-in env [:dependencies] (fnil conj []) dep))

(defn ns-tracker-pod []
(pod/make-pod (assoc-in (boot/get-env) [:dependencies] '[[ns-tracker "0.3.0"][org.clojure/tools.namespace "0.2.11"]])))

(defn garden-pool []
(defonce garden-pods
(pod/pod-pool (add-dep (boot/get-env) '[garden "1.2.5"])
:init (fn [pod] (pod/require-in pod 'garden.core))))

Expand All @@ -33,21 +33,21 @@
tmp (boot/tmp-dir!)
out (io/file tmp output-path)
src-paths (vec (boot/get-env :source-paths))
garden-pods (garden-pool)
ns-pod (ns-tracker-pod)]
(pod/with-eval-in ns-pod
(require 'ns-tracker.core)
(def cns (ns-tracker.core/ns-tracker ~src-paths)))
(boot/with-pre-wrap fileset
(when (or @initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))))
(let [c-pod (garden-pods :refresh)]
(if @initial (reset! initial false))
(util/info "Compiling %s...\n" (.getName out))
(io/make-parents out)
(pod/with-eval-in c-pod
(require '~ns-sym)
(garden.core/css {:output-to ~(.getPath out)
:pretty-print? ~pretty-print
:vendors ~vendors
:auto-prefix ~auto-prefix} ~css-var))))
(let [initial (not (contains? @processed css-var))]
(when (or initial (some #{ns-sym} (pod/with-eval-in ns-pod (cns))))
(let [c-pod (garden-pods :refresh)]
(when initial (swap! processed conj css-var))
(util/info "Compiling %s...\n" (.getName out))
(io/make-parents out)
(pod/with-eval-in c-pod
(require '~ns-sym)
(garden.core/css {:output-to ~(.getPath out)
:pretty-print? ~pretty-print
:vendors ~vendors
:auto-prefix ~auto-prefix} ~css-var)))))
(-> fileset (boot/add-resource tmp) boot/commit!))))

0 comments on commit 1c0264f

Please sign in to comment.