This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-05-18
Channels
- # announcements (2)
- # asami (20)
- # aws (4)
- # babashka (35)
- # beginners (47)
- # calva (65)
- # cider (19)
- # clj-kondo (63)
- # clojure (177)
- # clojure-austin (2)
- # clojure-europe (27)
- # clojure-nl (1)
- # clojure-uk (4)
- # clojurescript (13)
- # community-development (5)
- # conjure (5)
- # css (2)
- # data-oriented-programming (9)
- # datalevin (13)
- # datascript (15)
- # datomic (4)
- # devcards (6)
- # duct (4)
- # emacs (8)
- # funcool (1)
- # gratitude (2)
- # helix (3)
- # hyperfiddle (3)
- # introduce-yourself (1)
- # jobs (4)
- # jobs-discuss (26)
- # lambdaisland (2)
- # lsp (20)
- # malli (2)
- # meander (2)
- # mid-cities-meetup (5)
- # missionary (15)
- # music (4)
- # off-topic (37)
- # reagent (3)
- # reitit (2)
- # releases (2)
- # ring (18)
- # shadow-cljs (70)
- # specter (4)
- # sql (20)
- # timbre (3)
- # tools-build (43)
- # tools-deps (11)
- # vim (11)
- # xtdb (61)
what would be the easiest way to run something like this with a babashka task? I couldn’t quite get it to work with shell
or bb.process
ls functions/index.js | entr -r node functions/index.js
I'll send the process invocation later for what you have right now (on the phone now) but you can probably go via bash -c to the whole thing via bash
Why are you doing ls functions/index.js
?That's always going to return one file right?
yes, I think it could also be echo
or something, just need to pipe something into entr
OK, the way to do this with process or shell:
(shell {:in "functions/index.js\n"} "entr -r node functions/index.js")
oh that’s sweet with just shell
the fswatcher thing is also interesting, I may give this a go as well
because I think I may want to delete functions/index.js
at the start of this just to make sure I’m not running a wrongly configured file
Here is a full setup with bb tasks:
{:pods {org.babashka/fswatcher {:version "0.0.3"}}
:tasks {watch {:requires ([pod.babashka.fswatcher :as fw])
:task (do (fw/watch "project.clj"
(fn [event]
(when (#{:write :write|chmod} (:type event))
(shell "echo hello"))))
(deref (promise)))}}}
Documented it here: https://github.com/babashka/pod-babashka-fswatcher#usage-in-bbedn
I figure we want to inline version.txt when producing the script.
Not sure what behavior we want for src/babashka/neil.clj
. Leaving version undefined here is easiest.
Otherwise I guess
we could have a default function that tries to read version.txt
dynamically
and then when we build the neil
script we add an (alter-var-root version (constantly INLINED_STRING))
.
yes - but frankly, I didn't really understand why you chose to do it that way. Was it to get the same semantics for local development and resulting script?
(def raw-script (io/file "src" "borkdude" "deps.clj"))
(def version (-> (io/file "resources" "DEPS_CLJ_VERSION")
(slurp)
(str/trim)))
(def version-code "(def deps-clj-version
(-> (io/resource \"DEPS_CLJ_VERSION\")
(slurp)
(str/trim)))")
(def script
(str ";; Generated with script/gen_script.clj. Do not edit directly.\n\n"
(-> (slurp raw-script)
(str/replace #"(?i)\s*\(:gen-class\)" "")
(str/replace version-code (format "(def deps-clj-version %s)" (pr-str version))))
"\n(apply -main *command-line-args*)\n"))
(def clj-script
(str
"#!/usr/bin/env bb\n\n"
script))
https://github.com/borkdude/deps.clj/blob/bac835661adbcd06b07ce2c408bb3e4911a48c28/script/gen_script.clj#L8-L23I don't remember either. We could just hard-code the version in the source maybe and when bump the version (via bb publish), then we search and replace it.
do regexes work differently in bb.edn
targets from normal clj
files?
I'm able to use (re-pattern "version")
, but #"version"
gives me trouble.
Code generation (regex) seems to be working: https://github.com/babashka/neil/pull/39/files