             SourceFile
             CompilerOptions$LanguageMode]))
 
+(def js ".js")
+(def css ".css")
+(def html ".html")
+(def gz ".gz")
+
 (defn- delete-target [target]
   (let [f (file target)]
     (when (.exists f)
       (.delete f))
     (make-parents f)))
 
-(defn- find-assets [f ext]
-  (if (.isDirectory f)
-    (->> f
-         file-seq
-         (filter (fn [file] (-> file .getName (.endsWith ext)))))
-    [f]))
+(defn- find-assets [folder ext]
+  (if (not (.isDirectory folder))
+    [folder]
+    (->> folder
+         (file-seq)
+         (filter #(string/ends-with? (.getName %) ext)))))
 
-(defn- aggregate [path ext]
-  (if (coll? path)
-    (flatten
-     (for [item path]
-       (let [f (file item)]
-         (find-assets f ext))))
-    (let [f (file path)]
-      (find-assets f ext))))
+(defn- aggregate [paths ext]
+  (if (not (coll? paths))
+    (aggregate [paths] ext)
+    (->> paths
+         (map #(find-assets (file %) ext))
+         (flatten))))
 
 (defn total-size [files]
-  (->> files (map #(.length %)) (apply +)))
+  (->> files 
+       (map #(.length %))
+       (apply +)))
 
 (defn- create-temp-file [source]
-  (File/createTempFile (.getName source) ".gz"))
+  (File/createTempFile (.getName source) gz))
 
 (defn- create-temp-files [sources]
   (map create-temp-file sources))

        (for [[target path] assets]
          [[path target]
           (cond
             (.endsWith target ".js")  (minify-js path target opts)
             (.endsWith target ".css") (minify-css path target opts)
             :else (throw (ex-info "unrecognized target" target)))])))

(ns asset-minifier.core
  (:require [clojure.java.io :refer [file reader writer make-parents]]
            [clojure.string :as string]
            [clj-html-compressor.core :as html-comressor])
  (:import com.yahoo.platform.yui.compressor.CssCompressor
           java.util.zip.GZIPOutputStream
