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