This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-19
Channels
- # babashka (13)
- # beginners (4)
- # biff (1)
- # cider (15)
- # clerk (1)
- # clojure (18)
- # clojure-europe (10)
- # clojure-nl (1)
- # clojure-uk (1)
- # core-logic (2)
- # core-typed (2)
- # datomic (23)
- # defnpodcast (1)
- # emacs (4)
- # fulcro (25)
- # hyperfiddle (8)
- # music (1)
- # off-topic (21)
- # podcasts-discuss (1)
- # polylith (6)
- # releases (1)
- # squint (19)
- # tools-deps (10)
Hey! I'm using bb to automate things for cljs rn development and one of the things I need to do is call npx expo start --android
. I got something working using :inherit true
and now I'm all set but I was curious how I would make it work without :inherit true
i.e. if I wanted to capture output.
script/bb/android.clj
(ns bb.android
(:require [ babashka.process :refer [process]]))
(defn launch []
(process {:inherit true} "npm" "run" "android"))
script/bb/watch.clj
(ns bb.watch
(:require [ babashka.process :refer [shell process exec]]
[ :as io]))
(defn launch []
(shell {:out :string :err :string} "adb" "devices")
(let [p (promise)]
(doto
(Thread.
(fn []
(doseq [line (line-seq (io/reader (:out (process "npm" "run" "watch"))))]
(println (str "[watch] " line))
(when (seq (re-seq #"shadow-cljs - watching build :app" line))
(deliver p "booted")))))
(.start))
p))
bb.edn
{:paths ["script"]
:tasks {:requires ([bb.emulator :as emulator]
[bb.watch :as watch]
[bb.android :as android])
dev {:task (do
(let [watch (watch/launch)
emulator (emulator/launch)]
(deref watch)
(deref emulator)
(deref (android/launch))))}
emulator {:task (do
(shell "adb" "devices")
(deref (emulator/launch)))}
watch {:task (deref (watch/launch))}
android {:task (deref (android/launch))}}}
I'm able to call npm run watch
and re-seq on the lines for shadow-cljs - watching build :app
but I wasn't able to figure out how to do something similar for npx expo start --android
because that starts an interactive thing where I can hit a
to launch it or r
to reload it. I have a package.json
that aliases android
to npx expo start --android
...
I'm sure I'm not asking a clear question and I'm sorry about that. I just wanted ideas on how I could run an interactive program and re-seq
the output. I'm guessing I would have to get rid of :inherit
but I don't know what to use instead.
On another note, the first thing that I tried was this:
(defn launch []
(process {:in *in*
:out *out*
:err *out*}
"npm" "run" "android"))
Why doesn't that work?Ok, so it would work if pass some kind of InputStream to :in and copy and flush each byte from *in*
?
this might also help: https://twitter.com/borkdude/status/1628786679447269377