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