Skip to content

Instantly share code, notes, and snippets.

@micha
Forked from burn2delete/test.clj
Last active August 29, 2015 14:24
Show Gist options
  • Save micha/085e94c09376ee52bc97 to your computer and use it in GitHub Desktop.
Save micha/085e94c09376ee52bc97 to your computer and use it in GitHub Desktop.
(boot/deftask yaml-to-json
"Convert YAML file to JSON."
[]
(let [tmp (boot/tmp-dir!)]
(comp (boot/with-pre-wrap fileset
(doseq [f (->> fileset boot/input-files)]
(let [in-file (tmpd/file f)
in-path (tmpd/path f)
out-path (change-file-ext in-path "json")
out-file (io/file tmp out-path)
result (yaml/parse-string (slurp in-file))]
(doto out-file
io/make-parents
(spit out-path)))
(-> fileset (boot/add-resource tmp) boot/commit!))
(tasks/sift :to-source #{ #"\.yaml$" }))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment