added an error check for parsing the config.edn

This commit is contained in:
Yogthos 2015-04-02 22:22:17 -04:00
parent 97de91ca90
commit e0d3676196
2 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,4 @@
(defproject cryogen-core "0.1.20" (defproject cryogen-core "0.1.21"
:description "Cryogen's compiler" :description "Cryogen's compiler"
:url "https://github.com/lacarmen/cryogen-core" :url "https://github.com/lacarmen/cryogen-core"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"

View file

@ -266,23 +266,26 @@
(defn read-config (defn read-config
"Reads the config file" "Reads the config file"
[] []
(let [config (-> "templates/config.edn" (try
get-resource (let [config (-> "templates/config.edn"
slurp get-resource
read-string slurp
(update-in [:blog-prefix] (fnil str "")) read-string
(update-in [:rss-name] (fnil str "rss.xml")) (update-in [:blog-prefix] (fnil str ""))
(update-in [:rss-filters] (fnil seq [])) (update-in [:rss-name] (fnil str "rss.xml"))
(update-in [:sass-src] (fnil str "css")) (update-in [:rss-filters] (fnil seq []))
(update-in [:sass-dest] (fnil str "css")) (update-in [:sass-src] (fnil str "css"))
(update-in [:post-date-format] (fnil str "yyyy-MM-dd")) (update-in [:sass-dest] (fnil str "css"))
(update-in [:keep-files] (fnil seq [])) (update-in [:post-date-format] (fnil str "yyyy-MM-dd"))
(update-in [:ignored-files] (fnil seq [#"^\.#.*" #".*\.swp$"])))] (update-in [:keep-files] (fnil seq []))
(merge (update-in [:ignored-files] (fnil seq [#"^\.#.*" #".*\.swp$"])))]
config (merge
{:page-root (root-path :page-root config) config
:post-root (root-path :post-root config) {:page-root (root-path :page-root config)
:tag-root (root-path :tag-root config)}))) :post-root (root-path :post-root config)
:tag-root (root-path :tag-root config)}))
(catch Exception _
(throw (IllegalArgumentException. "Failed to parse config.edn")))))
(defn compile-assets (defn compile-assets
"Generates all the html and copies over resources specified in the config" "Generates all the html and copies over resources specified in the config"