Fork me on GitHub
#babashka
<
2023-07-03
>
mmer12:07:15

Sorry for a dumb question: I want to zip a directory and it just takes a relative file - how do I change the cwd when using fs?

borkdude13:07:22

you can adjust zip entries using the :path-fn option

borkdude13:07:44

oh and also you can use :root to change the cwd

mmer15:07:21

Thanks :path-fn worked. Would be good to have a second parameter so that the function knew the part of the path you want to remove. Just a nice to have.

borkdude15:07:34

That is what :root is for

mmer15:07:14

I will try that. Thanks

mmer15:07:45

I must have got that wrong.

reefersleep13:07:20

This might also be a dumb question 🙂 If I create code that's valid for both babashka and regular JVM Clojure (don't know if I'm even phrasing that right), except for like, the entrypoint for each, am I just a properly set up bb.edn file and project.clj/deps.edn file away from being "cross-platform"?

joakimen13:07:10

I think so yes, but you need to include whichever bb-libraries you are using (process, fs, cheshire, ..) in your deps.clj, as these will not be available when you run with clojure/clj otherwise

borkdude13:07:26

you can use one deps.edn for both. you can refer to the deps.edn from a bb.edn using {:deps {my.project {:local/root "."}}}

👍 2
☝️ 2
reefersleep13:07:36

Even smarter!

reefersleep13:07:41

Very nice 🙂

borkdude13:07:42

and then you can install your script with #C0400TZENE7

☝️ 2
reefersleep14:07:38

Cheers! I'll have to fiddle with this. I guess the bb.edn file can refer to the file containing ns that has the the bb entrypoint (that does like command line flag parsing and associated logic), which could be in some unusual place (like outside /src), which the deps.edn file could then safely ignore.

borkdude14:07:08

in bb.edn you can add :paths [".bb"] for extra bb-specific files

reefersleep14:07:55

I was thinking of exactly something like that 😅 Cheers both! @U0422G22932 @U04V15CAJ

👌 2
reefersleep13:07:11

I built a tiny lib that I was thinking I could run both as a bb program on the command line and as a regular old Clojure lib in a regular old, slow Clojure repl.

borkdude13:07:08

Please use threads ❤️

reefersleep13:07:23

Yes, sorry 😓

jjttjj17:07:12

Not a high priority or anything but I'm curious about the status of the websocket client for https://github.com/babashka/http-client? I've been using the websocket branch successfully for a while now on projects where I need a websocket client. Do you still eventually plan to merge that into the main branch?

borkdude17:07:42

did the branch work well for you?

borkdude17:07:49

if so, I guess I could merge it soon

jjttjj17:07:01

Yup no issues with it at all. I don't have any major feedback, except that the :on-message is lower level than most other (clojure) websocket client apis, giving you charbuffers intead of stings. But I personally welcome that as there are times when I can use the extra efficiency.