/src/leiningen/cljs_devmode_bootstrap.clj

http://github.com/maxweber/cljs-devmode · Clojure · 36 lines · 31 code · 5 blank · 0 comment · 2 complexity · f493951f3865a5f1bb354c8d21a2d4bd MD5 · raw file

  1. (ns leiningen.cljs-devmode-bootstrap
  2. (:use clojure.java.io
  3. leiningen.deps
  4. leiningen.jar
  5. [leiningen.cljs-devmode :only [check-clojurescript-home-param]]))
  6. (defn- dest-dir [clojurescript-path]
  7. (file (file clojurescript-path) "lib/"))
  8. (defn- copy-deps [dir]
  9. (let [libs (file "lib/dev")]
  10. (doall (map #(let [name (.getName %)
  11. dest-file (file dir name)]
  12. (copy % dest-file))
  13. (remove #(= "clojure-1.2.1.jar" (.getName %)) (.listFiles libs))))))
  14. (defn- build-and-copy-jar [project dest-dir]
  15. (let [jar-name (get-jar-filename project)
  16. jar-file (file jar-name)]
  17. (jar project)
  18. (copy jar-file (file dest-dir (.getName jar-file)))))
  19. (defn cljs-devmode-bootstrap
  20. [project & [clojurescript-path]]
  21. (when-let [clojurescript-path (check-clojurescript-home-param clojurescript-path)]
  22. (if-not (= (:name project) "cljs-devmode")
  23. (binding [*out* *err*]
  24. (println "Error: cljs-devmode-bootstrap must be invoked in the root folder of the cljs-devmode project (get the sources from GitHub: https://github.com/maxweber/cljs-devmode)"))
  25. (do
  26. (deps project)
  27. (let [dest (dest-dir clojurescript-path)]
  28. (copy-deps dest)
  29. (build-and-copy-jar project dest))))))
  30. (comment (cljsc/build "samples/hello/src" {:output-dir "samples/hello/out"
  31. :output-to "samples/hello/hello.js"}))