Skip to content

Commit fe315c6

Browse files
foopangdmitryn
authored andcommitted
Improve custom figwheel script usability
Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
1 parent f90e1a4 commit fe315c6

3 files changed

Lines changed: 33 additions & 25 deletions

File tree

env/dev/figwheel_api.clj

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,31 @@
4545
:id id))
4646
ids))
4747

48-
(defn start-cljs-repl []
49-
(hawk/watch! [{:paths ["resources"]
50-
:handler (fn [ctx e]
51-
(let [path "src/status_im/utils/js_resources.cljs"
52-
js-resourced (slurp path)]
53-
(spit path (str js-resourced " ;;"))
54-
(spit path js-resourced))
55-
ctx)}])
56-
(let [build-ids (if *command-line-args*
57-
(map keyword *command-line-args*)
58-
[:android])
59-
;; read project.clj to get build configs
60-
profiles (->> "project.clj"
61-
slurp
62-
read-string
63-
(drop-while #(not= % :profiles))
64-
(apply hash-map)
65-
:profiles)
66-
cljs-builds (get-in profiles [:dev :cljsbuild :builds])
67-
builds (get-builds build-ids cljs-builds)]
68-
(start-figwheel build-ids builds)
69-
(rfs/-main))
70-
(ra/cljs-repl))
48+
(defn start
49+
([]
50+
(start (if *command-line-args*
51+
(map keyword *command-line-args*)
52+
[:android])))
53+
([build-ids]
54+
(hawk/watch! [{:paths ["resources"]
55+
:handler (fn [ctx e]
56+
(let [path "src/status_im/utils/js_resources.cljs"
57+
js-resourced (slurp path)]
58+
(spit path (str js-resourced " ;;"))
59+
(spit path js-resourced))
60+
ctx)}])
61+
;; read project.clj to get build configs
62+
(let [profiles (->> "project.clj"
63+
slurp
64+
read-string
65+
(drop-while #(not= % :profiles))
66+
(apply hash-map)
67+
:profiles)
68+
cljs-builds (get-in profiles [:dev :cljsbuild :builds])
69+
builds (get-builds build-ids cljs-builds)]
70+
(start-figwheel build-ids builds)
71+
(rfs/-main))))
7172

72-
(start-cljs-repl)
73+
(def stop ra/stop-figwheel!)
74+
75+
(def start-cljs-repl ra/cljs-repl)

env/dev/run.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(ns dev-run
2+
(:use [figwheel-api]))
3+
4+
(start)
5+
(start-cljs-repl)

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
["do" "clean"
2020
["with-profile" "prod" "cljsbuild" "once" "ios"]
2121
["with-profile" "prod" "cljsbuild" "once" "android"]]
22-
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/figwheel_api.clj"]
22+
"figwheel-repl" ["run" "-m" "clojure.main" "env/dev/run.clj"]
2323
"test-cljs" ["with-profile" "test" "doo" "node" "test" "once"]
2424
"test-protocol" ["with-profile" "test" "doo" "node" "protocol" "once"]}
2525
:figwheel {:nrepl-port 7888}

0 commit comments

Comments
 (0)