Fork me on GitHub
#clojurescript
<
2019-09-15
>
ag03:09:37

Has anyone used with-open in Clojurescript? I’d like to implement something like IClosable and the only example I found is in planck-repl/planck core

ag03:09:25

and I’m not sure if I just copy it to my project or add plank as a dependency

ag03:09:46

I guess I’m gonna try using it as a library, it has a few other helpful functions as well

ag03:09:26

ah, that attempt didn’t work ;( No such namespace: paredit, could not locate paredit.cljs, paredit.cljc

ag04:09:39

I think that’s only happening with the latest version @mfikes

mfikes04:09:49

@ag The Planck JAR really only exists to help with tooling. So, it is useful when using Cursive (and its static analysis), and so that http://cljdoc.org can generate documentation for the namespaces, etc. (https://github.com/planck-repl/planck/issues/875 as well)

mfikes04:09:25

It can't really be used as a library because it is rife with dependencies on Planck itself.

ag04:09:21

would you ever consider making it a library?

mfikes04:09:47

Hrm. Much of the Planck library is there to expose its native facilities via Clojure-idiomatic namespaces. Having said that, there was an idea of factoring out those abstractions into a library that could be used, where the concrete implementations could be implemented by anything: https://github.com/abiocljs/abio

mfikes04:09:50

If you just want a with-open that can close something you know how to close, I'd just a macro to your project, though, and not take on a dep.

ag04:09:10

okay. thank you!

ag18:09:21

what’s the correct way to slurp file at the root of the project targeting nodejs? I can’t seem to find a way to detect the right dir. (js* "__dirname") returns something like “myproj/target/node/dev/figwheel”

nenadalm19:09:33

I use (def ^:private project-path (.cwd js/process)) to get root directory (https://nodejs.org/api/process.html#process_process_cwd). Note that you have to be in the project root directory when you're starting the node process though.

Roman Liutikov18:09:29

I think nodejs is not aware of classpath, so you probably have to do it manually somehow

ag18:09:02

> somehow but how though?

ag18:09:41

found it… I think

ag18:09:14

(:require [path])
  (.resolve path ".")

ag18:09:38

not sure how reliable it is though

dominicm18:09:51

I think that's reliable. It returns the cwd

ag18:09:37

yet somehow the following not working:

(:require [cljs-node-io.core :as io :refer [slurp spit]]
            path)
(slurp (path/join (.resolve path ".") "deps.edn"))
it path/join returns correct [full] path to deps.edn, yet io/slurp fails

ag19:09:19

cleared target re-started the REPL and it worked

Roman Liutikov19:09:45

I think more reliable approach would be to run node process with env var set to project root

dominicm19:09:13

You're right. If someone ran node in a different directory, it wouldn't work.

ag20:09:42

How do you combine promise chains of funcool/promesa with sync stuff, e.g.: if I have something like

(p/chain
  fill-username
  fill-password
 #(.click %)
How can I run this within deftest and assert the results?