Skip to content

Instantly share code, notes, and snippets.

@micha
Created November 20, 2014 20:09
Show Gist options
  • Select an option

  • Save micha/a4f5ac429b867b725224 to your computer and use it in GitHub Desktop.

Select an option

Save micha/a4f5ac429b867b725224 to your computer and use it in GitHub Desktop.
(set-env!
:resource-paths #{"src"}
:dependencies '[[tailrecursion/warp "0.1.0"]])
(require
'[clojure.java.io :as io])
(deftask mytask
"My demo task."
[]
(let [tmpdir (temp-dir!)]
(fn [next-task]
(fn [fileset]
(let [src-files (input-files fileset)
to-delete (atom [])]
(doseq [tf src-files]
(let [path (tmppath tf)
in-file (tmpfile tf)
out-file (io/file tmpdir (str path ".uc"))]
(when (.endsWith path ".lc")
(swap! to-delete conj tf)
(io/make-parents out-file)
(spit out-file (.toUpperCase (slurp in-file))))))
(-> fileset
(rm! @to-delete)
(add-resource! tmpdir)
commit!
next-task))))))
(deftask mytask2
"My demo other task."
[]
(let [server (delay :start-server-or-something)]
(fn [next-task]
(fn [fileset]
@server
(next-task fileset)))))
(deftask mytask3
"My demo other task."
[]
(comp (mytask) (mytask2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment