Skip to content

Commit

Permalink
#27: add {:as-is? true/false} to "load-config" fn
Browse files Browse the repository at this point in the history
  • Loading branch information
tolitius committed Jun 27, 2019
1 parent 24123ff commit daf67c6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cprop/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
;; :file "/path/to/file.edn"
;; :merge [{} {} {} ..])
(defn load-config [& {:keys [file resource merge]
:or {merge []}}]
:or {merge []}
:as opts}]
(let [config (merge-maps (ignore-missing-default from-resource resource)
(ignore-missing-default from-file file))]
(if (not-empty config)
(as-> config $
(apply merge-maps (cons $ merge))
(merge* $ (read-system-props))
(merge* $ (read-system-env)))
(merge* $ (read-system-props opts))
(merge* $ (read-system-env opts)))
(throw (RuntimeException. (str "could not find a non empty configuration file to load. "
"looked in the classpath (as a \"resource\") "
"and on a file system via \"conf\" system property"))))))
Expand Down

0 comments on commit daf67c6

Please sign in to comment.