Fork me on GitHub
#babashka
<
2021-07-06
>
Karol Wójcik09:07:31

Does scittle support #js literals? It seems to me that #js {:x 1} is not the same as (clj->js {:x 1})

borkdude10:07:31

There is a #sci channel for this as well. I am afk today but can look tonight

borkdude14:07:33

@UJ1339K2B Do you mean that:

user=>  #js {:x 1} 
#js {:x 1}
user=> (clj->js {:x 1})
#js {:x 1}
user=> (= #js {:x 1} (clj->js {:x 1})) 
false
the last thing returns false?

borkdude14:07:43

Welcome to JS where object equality isn't a thing, similar to Java

borkdude14:07:35

This is also false:

user=> (= #js {:x 1} #js {:x 1})
false

Karol Wójcik14:07:43

Hmm, actually I meant something different. I will try to provide a minimal repro for it :D

borkdude14:07:17

If you mean "nested" objects, that is a known difference. Maybe first try in "real" CLJS, to see if it's different from SCI

cfleming09:07:00

Babashka files can be either .clj or .cljc, correct?

lispyclouds10:07:45

Correct. bb supports reader conditionals too with its own being :bb

lispyclouds10:07:21

Also if we really wanna be detailed, files having a shebang #!/usr/bin/env bb regardless of the extension may be considered bb files too? 😄

cfleming10:07:55

I think anyone putting bb code in .cljs (or .perl) files will not have a good time in Cursive 🙂

lispyclouds10:07:50

true that! 😆

borkdude10:07:57

.bb is also sometimes used but not that frequently

Karen Liu15:07:16

Hi! I'm using babashka on Windows PowerShell, and I'm trying to run a script that goes into all the subdirectories of my current folder and extracts some data from a file called out that is in each of those subdirectories. This script gives proper output on MacOS (a vector with various non-zero values), but on Windows I'm running into a problem where the script runs, but it doesn't seem to access any of the files that I need it to access because it returns an empty vector. This is the function that reads the files and dumps all the needed data into a single vector: (defn all-log-vecs [] "Assumes log files are in subdirectories and all named 'out'." (map #(read-string (str "[" (slurp %) "]")) (map str (fs/glob "." "*/out")))) Is there an issue with the arguments inside fs/glob that explains why this isn't working on Windows?

borkdude16:07:14

@klliu23 Hello Karen, welcome. I think glob works a bit differently on Windows unfortunately. Let me look it up for you

borkdude16:07:13

take a look at these docs here: https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String) I think those will explain what you should do on Windows

borkdude16:07:41

It beats me why they made the syntax different on Windows, but I decided to not mess with this in bb and just expose the Java stuff directly

borkdude16:07:32

I think the pattern you're looking for on Windows is "*\\\\out"

borkdude16:07:30

You can see which OS you are on with (System/getProperty "os.name")

Karen Liu16:07:37

Thank you so much! The Java docs and your suggestion were very helpful.

rwstauner20:07:27

i wish there was a syntax like (chdir "x" (...)) for bb tasks, but it sounds like doing that in java is dubious, which is probably why it doesn't already exist in clojure 😕 i found this as an example: https://github.com/arohner/lein-daemon/blob/master/daemon-runtime/src/leiningen/daemon/runtime.clj#L11

borkdude20:07:40

Technically it's possible, but not without caveats. Note that clojure and shell already support :dir in tasks

borkdude20:07:05

However, there is a fix for clojure on master regarding this

borkdude20:07:45

So if you're using it with that, for now use a binary from #babashka-circleci-builds

borkdude21:07:52

I think I'll can do a release later this week with that fix

rwstauner21:07:16

yeah i was hoping to influence shell and babashka.fs

borkdude21:07:45

ok, shell already works with :dir so that's fine

borkdude21:07:01

(shell {:dir ...} "ls")

rwstauner21:07:25

yeah, i was looking for a nice "do everything" syntax (automatically setting the dir for shell and fs)

rwstauner21:07:42

for now i am passing dir to shell and including that in the fs calls

rwstauner21:07:53

it's fine, just not as concise

borkdude21:07:09

is your code open source?

rwstauner21:07:59

not this particular project

rwstauner21:07:24

the difference would be something like this:

(let [js (str (fs/path "target" "lambda" "lambda.js"))
      zip (str js ".zip")]
  (shell {:dir proj} "...")
  (fs/delete-if-exists (fs/path proj zip))
  (shell {:dir proj} "..."))


(let [js (str (fs/path "target" "lambda" "lambda.js"))
      zip (str js ".zip")]
  (chdir proj
    (shell "...")
    (fs/delete-if-exists zip)
    (shell "....")))

rwstauner21:07:58

so, nothing that can't be worked around, just thought it would be a really nice syntax

borkdude21:07:06

yeah, I think raynes/fs had a *dir* dynamic var, but that only works for that namespace. I think if tasks would introduce such a var, I would have to curate every library inside bb to see if it makes sense to respect that var or not and users would also have to guess if bb did this :)

rwstauner21:07:29

yeah, that seems to be the issue 🙂

rwstauner21:07:46

no sweat. thanks!