PageRenderTime 40ms CodeModel.GetById 21ms app.highlight 4ms RepoModel.GetById 14ms app.codeStats 0ms

/src/leiningen/cljs_devmode_bootstrap.clj

http://github.com/maxweber/cljs-devmode
Clojure | 36 lines | 31 code | 5 blank | 0 comment | 0 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
 7(defn- dest-dir [clojurescript-path]
 8  (file (file clojurescript-path) "lib/"))
 9
10(defn- copy-deps [dir]
11  (let [libs (file "lib/dev")]
12    (doall (map #(let [name (.getName %)
13                       dest-file (file dir name)]
14                   (copy % dest-file))
15                (remove #(= "clojure-1.2.1.jar" (.getName %)) (.listFiles libs))))))
16
17(defn- build-and-copy-jar [project dest-dir]
18  (let [jar-name (get-jar-filename project)
19        jar-file (file jar-name)]
20    (jar project)
21    (copy jar-file (file dest-dir (.getName jar-file)))))
22
23(defn cljs-devmode-bootstrap
24  [project & [clojurescript-path]]
25  (when-let [clojurescript-path (check-clojurescript-home-param clojurescript-path)]
26    (if-not (= (:name project) "cljs-devmode")
27      (binding [*out* *err*]
28        (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)"))
29      (do
30        (deps project)
31        (let [dest (dest-dir clojurescript-path)]
32          (copy-deps dest)
33          (build-and-copy-jar project dest))))))
34
35(comment (cljsc/build "samples/hello/src" {:output-dir "samples/hello/out"
36                                        :output-to "samples/hello/hello.js"}))