Skip to content

Commit

Permalink
Print warning if environ values are overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
malesch committed Jan 27, 2018
1 parent 6c2d05c commit 84e2af8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion environ/src/environ/core.clj
Expand Up @@ -36,9 +36,20 @@
(into {} (for [[k v] (edn/read-string (slurp env-file))]
[(sanitize-key k) (sanitize-val k v)])))))

(defn- warn-on-overwrite [ms]
(doseq [[k kvs] (group-by key (apply concat ms))
:let [vs (map val kvs)]
:when (and (next kvs) (not= (first vs) (last vs)))]
(println "Warning: environ value" (first vs) "for key" k
"has been overwritten with" (last vs))))

(defn- merge-env [& ms]
(warn-on-overwrite ms)
(apply merge ms))

(defonce ^{:doc "A map of environment variables."}
env
(merge
(merge-env
(read-env-file ".lein-env")
(read-env-file (io/resource ".boot-env"))
(read-system-env)
Expand Down

0 comments on commit 84e2af8

Please sign in to comment.