Fork me on GitHub
#babashka
<
2022-09-16
>
borkdude09:09:11

Added some more bbin-installable tools to borkdude/tools :-D - ls_jar and nrepl_proxy https://github.com/borkdude/tools

🔥 1
borkdude21:09:00

@U7YNGKDHA For env variables, you can do it like this:

(shell {:extra-env {"FOO" "BAR"}} "some-command" "arg")

borkdude21:09:40

bb also has a built-in clojure runner which does not require you to install anything and also works well in Windows. Shelling out to Powershell clj is sometimes problematic.

(clojure {:extra-env {"FOO" "BAR"}} "-M:foo" "arg")

👍 1
🎅 1
borkdude21:09:33

Thanks for the video!

Jacob O'Bryant22:09:10

Thanks for the tips! Re: env vars, I'm still wondering about what the most ergonomic way to set them would be--e.g. say I have a bb.edn file like this, which depends on tasks defined in another project:

{:deps {local/deps {:local/root "."}}
 :tasks {dev          com.platypub.themes.common.tasks/dev
         build        com.platypub.themes.common.tasks/build
         clean        com.platypub.themes.common.tasks/clean
         css          com.platypub.themes.common.tasks/css
         -on-save     com.platypub.themes.common.tasks/-on-save
         render-site  
         render-email com.platypub.themes.default.email/-main
         config       com.platypub.themes.default.config/-main}}
And then I'd like to have env vars stored in their own file (say, env.sh or env.edn) and gitignored, so people can set their own values. Using shell seems like it would be a bit awkward here, though I suppose not terrible:
{:deps ...
 :tasks {dev (shell {:extra-env (edn/read-string (slurp "env.edn"))}
                    "bb" "-m" "com.platypub.themes.common.tasks/dev")
         ...}}
I suppose it might be easier to uses a env.sh file and run source env.sh before calling bb. Though that would either be inconvenient (user has to remember to run source env.sh on their before they start working on a project) or would require a wrapper script, which would mean users would have to remember to type e.g. ./task dev instead of bb dev (which in the case of biff is actually what they're already doing, but it'd be nice to standardize on bb). Is there by chance some kind of option for bb that I missed? e.g. something like this would be great:
{:deps ...
 :env (edn/read-string (slurp "env.edn"))
 :tasks {dev com.platypub.themes.common.tasks/dev
         ...}}

Jacob O'Bryant22:09:58

actually maybe what I should do is just keep the variables in an edn file and as a convention write all my tasks so they read from there instead of reading an environment var. And then when tasks need to set environment vars for things they call, the :extra-env option will be fine. I guess that's a fairly standard approach, e.g. tailwind.config.js

👍 1
borkdude22:09:44

I think that would work best. Going to catch some zzzs here now!

Jacob O'Bryant22:09:16

Sounds good! I'll have more questions for you later 😉

Cora (she/her)20:09:35

I have a bunch of little scripts that'd be perfect for bbin

borkdude20:09:28

(I have a bunch more in my local bin folder that I'll port as I use them)

Cora (she/her)20:09:48

I should give them proper help text and command-line args

Cora (she/her)20:09:19

they typically just read stdin and write to stdout for chaining

borkdude20:09:21

Check out #babashka-cli for that