Skip to content

Instantly share code, notes, and snippets.

@jeaye
Last active October 26, 2017 12:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeaye/9a57740fc474a60a050ae68acf714c4d to your computer and use it in GitHub Desktop.
Save jeaye/9a57740fc474a60a050ae68acf714c4d to your computer and use it in GitHub Desktop.
;; Dependency
[environ "1.1.0"]
;; Profiles
:profiles {:dev {:env {:dev "true"}}
(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})))
(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