This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-24
Channels
- # announcements (22)
- # babashka (33)
- # babashka-sci-dev (161)
- # beginners (25)
- # calva (57)
- # cider (6)
- # clara (6)
- # clerk (14)
- # clj-kondo (24)
- # clojars (10)
- # clojure (65)
- # clojure-austin (1)
- # clojure-conj (2)
- # clojure-europe (23)
- # clojure-miami (3)
- # clojure-nl (3)
- # clojure-norway (3)
- # clojure-uk (3)
- # clojurescript (28)
- # cursive (24)
- # datomic (136)
- # emacs (38)
- # graalvm (29)
- # graphql (3)
- # introduce-yourself (8)
- # jackdaw (4)
- # jobs-discuss (9)
- # malli (5)
- # nbb (36)
- # off-topic (11)
- # pathom (58)
- # polylith (2)
- # practicalli (1)
- # re-frame (5)
- # reagent (11)
- # releases (1)
- # remote-jobs (8)
- # sci (15)
- # shadow-cljs (31)
- # slack-help (2)
- # spacemacs (11)
- # sql (7)
- # tools-build (9)
This is a beginner question - I am basically just reading a file and I want to print it out. This is what I have:
(defn get-concerto [concerto]
(slurp (str local-dir concerto)))
(p/let [concert (get-concerto “test.cto”)]
(prn concert))
This is what I get:
#<Promise[~]>
This is super basic get-concerto returns a promise. I want to see the value - The contents of the file I am retreiving. I thought the let helped with this - Maybe I need an await in there (get-concerto “test.cto”) #<Promise[~]>
The let will get you a local that binds to the value but the let expression itself returns a promise. You can't break out of a promise. If you want, you can also use fs/readFileSync
any idea why I'm getting this? Error: Namespace name must be symbol, got: [object Object] my nbb nrepl via calva blows up with this error after running some promises, I'm not doing anything too interesting, require style is the same as cljs from the docs right, like ["fs" :as fs]
Kk thx I'll look more and come back if necessary I'm sorry just thought you might recognise it
(ns release
(:require
["child_process" :as child-process]
[clojure.string :as string]
[exec-nbb :as en :refer [ps-run w-kg-dir]]
[promesa.core :as p]))
(defn release []
(p/do
(println 1)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"rm -r .shadow-cljs")
(println 2)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"rm -r .\\public")
(println 3)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"npx shadow-cljs release tab-app")
(println 4)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"npx shadow-cljs release tab-backend")
(println 5)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"cp assets\\index.html public\\index.html")
(println 6)
(ps-run {"cwd" "C:\\Users\\Administrator\\projects\\kangrok_build_dir\\kangrok-core"}
"cp assets\\simple_main.js public\\assets\\app\\js\\simple_main.js")))
it's doing this, then the other ns header looks like this and is just some tiny wrappers around child process and promises
but don't worry it's not a real blocker was just hoping you might just recognize it, I will work around it and come back at some point and narrow down the source
I'm just using nbb to incrementally script my release process, so every time it's slightly more scripted instead of being manual commands or a shell script
cool. Normal bb might be an easier fit for this, but cool to see that you're using nbb for it
for removing files, you can avoid shelling out, with babashka fs, :
(fs/delete-tree ...)
I don't use clj other than to compile my cljs and I've day insha'Allah I'll master self hosted
Thx that's interesting, the code is ugly I'm just incrementally trying to migrate from the shell didn't know it had those built in
well, normal bb has babashka.fs
- nbb doesn't. but "fs"
from node has a lot of this stuff too
and by using that instead of shelling out, your code will become more cross platform too
My npm list gives:
npm list
[email protected] /Users/tmb/Coding/Clojure/cljacc
├── @accordproject/[email protected]
└── [email protected]
I have:
(ns concert
(:require [“@accordproject/concerto-core” :as concerto]
[nbb.core :refer [slurp]]
[promesa.core :as p]
[“readfilesync” :as fs]
[clojure.string :as str])
)
I get:
cljs꞉concert꞉>
; ENOENT: no such file or directory, scandir '/Users/tmb/Coding/Clojure/cljacc/node_modules/readfilesync/Users/tmb/Coding/Clojure/cljacc'
It seems to have duplicated ‘Users/tmb/coding/Clojure’
@U054219BT Did you intend to use this package? It seems to contain pure nonsense https://www.npmjs.com/package/readfilesync?activeTab=explore