find-assets handles get-resource returning nilern

- this can/will happen if a user doesn't have a resource root directory,
  e.g. if the resources/templates/asc/posts directory doesn't exist.
This commit is contained in:
Adam Tankanow 2015-01-11 14:20:10 -05:00
parent cb18e5734d
commit 8ff3f19362

View file

@ -22,11 +22,18 @@
matches (map #(re-find % name) ignored-files)] matches (map #(re-find % name) ignored-files)]
(not (some seq matches))))) (not (some seq matches)))))
(defn find-assets [f ext ignored-files] (defn find-assets
(->> (get-resource f) "Find all assets in the given root directory (f) and the given file
file-seq extension (ext) ignoring any files that match the given (ignored-files).
(filter (ignore ignored-files)) First make sure that the root directory exists, if yes: process as normal;
(filter (fn [file] (-> file .getName (.endsWith ext)))))) if no, return empty vector."
[f ext ignored-files]
(if-let [root (get-resource f)]
(->> (get-resource f)
file-seq
(filter (ignore ignored-files))
(filter (fn [file] (-> file .getName (.endsWith ext)))))
[]))
(defn create-folder [folder] (defn create-folder [folder]
(let [loc (io/file (str public folder))] (let [loc (io/file (str public folder))]