Skip to content

Commit

Permalink
Stop throwing reader is nil when assets don't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Walker committed Oct 30, 2018
1 parent 63c2b13 commit c2b4b69
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/coast/assets.clj
Expand Up @@ -52,17 +52,16 @@
(pprint/write val))))

(defn bundle [coast-env bundle-name]
(if (= "prod" coast-env)
(-> (io/resource "assets.minified.edn")
(slurp)
(edn/read-string)
(get bundle-name))
(let [m (-> (io/resource "assets.edn")
(slurp)
(edn/read-string))]
(get (->> (map (fn [[k v]] {k (hrefs (ext k) v)}) m)
(apply merge))
bundle-name))))
(let [s (if (= "prod" coast-env) "assets.minified.edn" "assets.edn")
res (io/resource s)]
(if (some? res)
(let [m (-> res slurp edn/read-string)]
(if (= "prod" coast-env)
(get m bundle-name)
(get (->> (map (fn [[k v]] {k (hrefs (ext k) v)}) m)
(apply merge))
bundle-name)))
(println "Warning: You're trying to load" s "but it doesn't exist! Run `COAST_ENV=prod make assets` for minified, bundled assets in production"))))

(defn -main []
(let [m (-> (io/resource "assets.edn")
Expand Down

0 comments on commit c2b4b69

Please sign in to comment.