Fork me on GitHub
Steffen Glückselig10:02:06

Concerning dependent tasks: Am I right in that the return-value of a task can be accessed via its name in the :depends-array - like -jar-file in

jar {:depends [-target -jar-file]
     :task (when (seq (fs/modified-since -jar-file
                                    (fs/glob "src" "**.clj")))
             (spit -jar-file "test")
             (println "made jar!"))}



🙂 1
🚀 1

Idea. When running multiple babashka tasks in parallell, I'd love to see a prefix + coloring to differentiate between output from the different parallel processes. I think Docker Compose does something similar. Kind of hard to know which log line is from with process otherwise. Not sure if this makes sense to provide as functionality from the task runner itself, or if it can just be a "wrapper" / "function" / something in "userspace" that we could write and change ourself.


Good idea, but not sure how feasible this is. This requires several changes on several levels. All printing to stdout should be intercepted from normal println as well as processes invoked with babashka.process,, ProcessBuilder, etc.


I would love to be able to replace foreman with babashka


That's kind of the idea of parallel tasks :)

❤️ 1

Yes I've been meaning to use parallel tasks in some smaller projects. But at work I use foreman for running databases and it can get quite chatty in the logs, so the colored output helps. The Procfile runs 2 apps and 3 DBs and it needs various env vars set to work correctly, which would be cleaner if it was just a babashka task or script


As a current solution: possibly there is a bash/unix programs which can prepend the output of a process with some prefix/color, which you can then use to compose in babashka.process?

👍 1

I guess this works:

yes | while read line; do echo "[ERROR] $line"; done
and you could wrap that while read in a babashka script even.


Will give that a try. Of course I could just consume the output of the process and prepend to each line. Since the --config flag was added I've been meaning to give that a try


I think you could solve this at the babashka process level by manually handling the output, although it would be nice if babashka process had something like this built-in. (process ["foo" "bar"] {:color :green :prepend "FOO"})


and then shell in tasks could also have that (since it's just a wrapper around process)


that would be a good first step I assume


Will add some discussion to that issue 🙂


Here's a snippet from what I'm doing right now. frontend is a normal bash function that runs the frontend. Essentially, with_prefix is meant to be used as a pipe that takes either stdout or stderr as input, and "colors and adds prefixes" as required.


(sorry I kind of fired off a question and went dark, I have a hard time keeping focus on what I'm working on right now unless I turn off Slack)


@teodorlu Awesome, yeah, that's kind of what would become an option in babashka process (and could be done manually now by processing lines of output in babashka process).

👍 1

I would be very happy if I could delete all that bash and replace with a bb.edn 🙂


Thanks for brainstorming :)


Happy to chime in when I can ❤️


Quickly skimmed the, really like the process, deref and check API. Intresting fusion of unixy and lispy design.

❤️ 1

@teodorlu regarding use of color in bb output, I remember seeing that @lee did something cool in rewrite-clj with :enter and :leave tasks where every task got a nice colorized task started, task done. Your questions reminded me of that.

👀 1
👋 1

Nice! Thanks for letting me know, this is interesting.


My eyes are old. They need this kind of thing now! 🙂


What I do is bb some-file.clj | puget - this works great if your babashka script outputs edn data


But maybe that is a different use case


Yeah, is really just targeted for creating heading, warnings, and errors that pop out.

👀 1