Improve custom figwheel script usability

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
This commit is contained in:
Foo Pang 2018-01-06 09:02:20 +08:00 committed by Dmitry Novotochinov
parent f90e1a4ed3
commit fe315c619a
No known key found for this signature in database
GPG Key ID: 267674DCC86628D9
3 changed files with 33 additions and 25 deletions

View File

@ -45,7 +45,12 @@
:id id)) :id id))
ids)) ids))
(defn start-cljs-repl [] (defn start
([]
(start (if *command-line-args*
(map keyword *command-line-args*)
[:android])))
([build-ids]
(hawk/watch! [{:paths ["resources"] (hawk/watch! [{:paths ["resources"]
:handler (fn [ctx e] :handler (fn [ctx e]
(let [path "src/status_im/utils/js_resources.cljs" (let [path "src/status_im/utils/js_resources.cljs"
@ -53,11 +58,8 @@
(spit path (str js-resourced " ;;")) (spit path (str js-resourced " ;;"))
(spit path js-resourced)) (spit path js-resourced))
ctx)}]) ctx)}])
(let [build-ids (if *command-line-args*
(map keyword *command-line-args*)
[:android])
;; read project.clj to get build configs ;; read project.clj to get build configs
profiles (->> "project.clj" (let [profiles (->> "project.clj"
slurp slurp
read-string read-string
(drop-while #(not= % :profiles)) (drop-while #(not= % :profiles))
@ -66,7 +68,8 @@
cljs-builds (get-in profiles [:dev :cljsbuild :builds]) cljs-builds (get-in profiles [:dev :cljsbuild :builds])
builds (get-builds build-ids cljs-builds)] builds (get-builds build-ids cljs-builds)]
(start-figwheel build-ids builds) (start-figwheel build-ids builds)
(rfs/-main)) (rfs/-main))))
(ra/cljs-repl))
(start-cljs-repl) (def stop ra/stop-figwheel!)
(def start-cljs-repl ra/cljs-repl)

5
env/dev/run.clj vendored Normal file
View File

@ -0,0 +1,5 @@
(ns dev-run
(:use [figwheel-api]))
(start)
(start-cljs-repl)

View File

@ -19,7 +19,7 @@
["do" "clean" ["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"] ["with-profile" "prod" "cljsbuild" "once" "ios"]
["with-profile" "prod" "cljsbuild" "once" "android"]] ["with-profile" "prod" "cljsbuild" "once" "android"]]
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/figwheel_api.clj"] "figwheel-repl" ["run" "-m" "clojure.main" "env/dev/run.clj"]
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"] "test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]} "test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]}
:figwheel {:nrepl-port 7888} :figwheel {:nrepl-port 7888}