Skip to content

Instantly share code, notes, and snippets.

@micha
Created January 18, 2015 21:09
Show Gist options
  • Select an option

  • Save micha/9f573a00895133562f45 to your computer and use it in GitHub Desktop.

Select an option

Save micha/9f573a00895133562f45 to your computer and use it in GitHub Desktop.
(defn externs
"Middleware to add externs files (i.e. files with the .ext.js extension) and
Google Closure libs (i.e. files with the .lib.js extension) from the fileset
to the CLJS compiler options."
[{:keys [tmp-src tmp-out main files opts] :as ctx}]
(let [ext-paths (map core/tmppath (:exts files))
lib-ins (map core/tmpfile (:libs files))
renamelib #(.replaceAll % "\\.lib\\.js$" ".js")
merge-cfg (partial merge-with (comp vec distinct into))
lib-paths (->> (map (comp renamelib core/tmppath) (:libs files))
(map #(.getPath (io/file tmp-out %))))]
(doseq [[in out] (map list lib-ins lib-paths)]
(file/copy-with-lastmod (io/file in) (io/file out)))
(update-in ctx [:opts] merge-cfg {:libs lib-paths :externs ext-paths})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment