-
-
Save jeaye/9a57740fc474a60a050ae68acf714c4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Dependency | |
[environ "1.1.0"] | |
;; Profiles | |
:profiles {:dev {:env {:dev "true"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns my-app.core | |
(:require [my-app.macro-util :refer-macros [when-dev]])) | |
(defn init! [] | |
; With other various setup code ... | |
(when-dev | |
(do | |
(st/instrument) | |
(verify-instrumentation!))) | |
; Recommended for good spec output | |
(set! s/*explain-out* (expound/custom-printer {:show-valid-values? true}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns my-app.macro-util | |
(:require #?(:clj [environ.core :refer [env]]))) | |
#?(:clj (defmacro if-fn [fun if-forms else-forms] | |
(if (fun) | |
if-forms | |
else-forms))) | |
#?(:clj (defmacro if-dev [if-forms else-forms] | |
`(if-fn ~#(some? (:dev env)) ~if-forms ~else-forms))) | |
#?(:clj (defmacro when-dev [if-forms] | |
`(if-dev ~if-forms nil))) | |
#?(:clj (defmacro if-staging [if-forms else-forms] | |
`(if-fn ~#(some? (:staging env)) ~if-forms ~else-forms))) | |
#?(:clj (defmacro when-staging [if-forms] | |
`(if-staging ~if-forms nil))) | |
#?(:clj (defmacro if-prod [if-forms else-forms] | |
`(if-fn ~#(some? (:production env)) ~if-forms ~else-forms))) | |
#?(:clj (defmacro when-prod [if-forms] | |
`(if-prod ~if-forms nil))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment