Introduce with-cljs-devtools-prefs macro

This commit is contained in:
Antonin Hildebrand 2017-10-30 19:25:44 +01:00
parent 8ce90653dc
commit 77068d3b5d
1 changed files with 10 additions and 0 deletions

View File

@ -5,3 +5,13 @@
"Reads a file as a string. Slurp is wrapped in a macro so it can interact with local files before clojurescript compilation." "Reads a file as a string. Slurp is wrapped in a macro so it can interact with local files before clojurescript compilation."
[path] [path]
(slurp (io/resource path))) (slurp (io/resource path)))
(defmacro with-cljs-devtools-prefs [prefs & body]
`(let [previous-config# (devtools.prefs/get-prefs)
prefs# ~prefs]
(try
(devtools.prefs/set-prefs! prefs#)
~@body
(finally
(assert (= (devtools.prefs/get-prefs) prefs#) "someone modified devtools.prefs behind our back!")
(devtools.prefs/set-prefs! previous-config#)))))