Fork me on GitHub
#babashka
<
2023-01-30
>
Arun02:01:43

Hi @borkdude could you do me a favor? Could you re-star my repo again? I had to reset the git repo to remove my actual legal name from the git commits: https://github.com/arunthecoder97/pandoc-spiceland

1
borkdude10:01:44

It seems cljfmt.core works with babashka:

bb -Sdeps '{:deps {cljfmt/cljfmt {:mvn/version "0.9.2"}}}' -e "(require '[cljfmt.core]) (println (cljfmt.core/reformat-string (slurp \"/tmp/dude/foo.cljs\")))"

clojure-spin 1
borkdude20:01:01

Using eftest with tasks and get reasonable output in github actions (not hundreds of progress lines):

test:bb  {:extra-deps {eftest/eftest {:mvn/version "0.6.0"}}
            :extra-paths ["test"]
            :requires ([eftest.runner :refer [find-tests run-tests]])
            :task (let [{:keys [fail error]} (run-tests
                                              (find-tests "test")
                                              (when-not (System/console)
                                                ;; better output in github actions
                                                {:report clojure.test/report}))]
                    (when (or (pos? fail)
                              (pos? error))
                      (throw (ex-info "Tests failed" {:babashka/exit 1}))))}}}

Sam Ritchie20:01:15

Is there some way to run a cleanup task, if the user kills some long-running task?

Sam Ritchie20:01:45

I have

clerk-watch
  {:doc "Start a shadow-cljs watch process that generates this project's custom JS."
   :task (X "clojure -X:nextjournal/clerk user/start!")}
and it would be nice to run
user/stop!
on exit… I see as I’m typing this that that doesn’t make sense though

Sam Ritchie20:01:48

since we’re invoking clojure

Sam Ritchie20:01:01

I would have to do it from inside the clojure fn

borkdude20:01:02

You can do this with a shutdown hook, both in bb and clojure

👍 1
borkdude20:01:02

test/babashka/shutdown_hook_test.clj
17:  (let [script "(-> (Runtime/getRuntime) (.addShutdownHook (Thread. #(println \"bye\"))))"

🙏 1