This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-03
Channels
- # aws (3)
- # babashka (46)
- # bangalore-clj (2)
- # beginners (89)
- # cider (1)
- # clojure (57)
- # clojurescript (4)
- # conjure (6)
- # duct (3)
- # fulcro (2)
- # graalvm-mobile (41)
- # introduce-yourself (1)
- # lsp (12)
- # malli (11)
- # off-topic (37)
- # pathom (3)
- # pedestal (6)
- # podcasts-discuss (5)
- # polylith (17)
- # releases (2)
- # sci (2)
- # shadow-cljs (8)
- # specter (1)
- # tools-deps (10)
What's the most elegant way to get the equivalent of something like ls *.log
, with a result that is a sequence of the file name strings, in my babashka script? I tried using sh
but couldn't make it work with the *
. I resorted to the following which works but it seems like there must be a much better way:
(filter #(= ".log" (apply str (take-last 4 %)))
(map #(.getName %) (.listFiles (File. "."))))
Nice. So it seems the equivalent of the code I posted above, if I've done (require '[babashka.fs :as fs])
, is:
(map fs/file-name (fs/glob "." "*.log"))
I am preparing a monorepo where each subproject has its own bb.edn
file. However, there are sets of useful tasks that I'd like to reuse in some of them.
What would you recommend for avoiding any copy/pasting?
you can put them in a common place like https://github.com/wilkerlucio/pathom-viz/blob/master/src/tasks/tasks.clj then refer them in the corresponding bb.edns like https://github.com/wilkerlucio/pathom-viz/blob/master/bb.edn
Indeed, that's what I have been doing but it still implies copying the tasks themselves, and if you change the :doc
you have to do it everywhere, for instance. So it was getting messy.
All right, using the heavy artillery then 😛
Related to previous but different. For very common tasks that end up pretty much in all subprojects (eg. test
), I am trying to define them in my root bb.edn
and specify a :dir
when calling (clojure ...)
(where a subproject lives and has its deps.edn
file).
However I am having an issue with a dep that points to a :local/root
:
Error building classpath. Manifest type not detected when finding deps ...
In spite of the path to that jar being correct. Doesn't happen when executing directly from the subproject dirDoes it happen when you use (shell {:dir ...} "clojure ...")
instead? if not, then it might be a bug somewhere in bb
It seems to work using shell
, yes
Yep, all is perfect from what I see
Sure if I manage to reproduce it 🙂
Is you can still reproduce it locally, it might also be a caching issue (in .cpcache)
@UCFG3SDFV I was able to reproduce it: https://github.com/babashka/babashka/issues/914
This happens because the clojure task is a 2 step process: 1) deps resolved using tools.deps.alpha, 2) the actual clojure JVM process. But the options currently only apply against the second step where the process is launched.
ok, I think I fixed it on master. Could you try out a binary from master? Available in #babashka-circleci-builds in a few minutes
don't remember which os you use, bit here's a linux one: https://20537-201467090-gh.circle-artifacts.com/0/release/babashka-0.4.7-SNAPSHOT-linux-amd64.tar.gz
For me at least it works locally now:
borkdude@MBP2019 /tmp $ bb -e '@(babashka.deps/clojure ["-Sforce" "-M" "-r"] {:dir "proj1"})'
Clojure 1.10.1
user=> (require 'medley.core)
nil
@UCFG3SDFV ok, made some more tests + fixes. I think it should be good now... https://20567-201467090-gh.circle-artifacts.com/0/release/babashka-0.4.7-SNAPSHOT-linux-amd64.tar.gz
@U04V15CAJ Excellent, I'll give it a go tomorrow, thanks
Seems to work fine now, REPL starts and classpath is properly computed 🙂
Haven't mentioned it here yet, but yesterday I made a CLI that exposes specter so you can use its DSL to filter/transform some EDN from stdin: https://github.com/borkdude/specter-cli/releases
is there a way to get the path to the currently in use babashka interpreter? something like $0
? so that i could call the same bb to run a child script without needing it to be in $PATH
?
$ bb -e '(-> (java.lang.ProcessHandle/current) .info .command .get)'
"/Users/borkdude/Dropbox/bin/bb"
I documented it here: https://github.com/babashka/babashka/wiki/Bash-and-Babashka-equivalents#current-process-executable
@deleted-user You could, but jet
also already has a query language and the --func
option for normal Clojure functions
Same here, that's why I just use jet
with either --query
or --func
. I don't know yet about adding specter to jet, I actually am not that experienced with it, but someone in the #sci wanted it to use together with sci, so I made it work for that reason
cool. sometimes I also just use bb for json. some people have aliases for that (https://twitter.com/quoll/status/1401141320010420232)
I think @nate also shared one back in the early days where you could provide an expression, it's not so hard to figure out
oh I found something: https://twitter.com/ndj/status/1249505127729213441
and then I shared another one here: https://twitter.com/borkdude/status/1249818512295632897