Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider different method of enabling printing for Node.js #192

Open
jafingerhut opened this issue Aug 11, 2019 · 0 comments
Open

Consider different method of enabling printing for Node.js #192

jafingerhut opened this issue Aug 11, 2019 · 0 comments

Comments

@jafingerhut
Copy link

From some testing with cljs-test-runner, which uses doo, it seems that doo calls the ClojureScript function enable-console-print! during initialization of a Node.js-based ClojureScript runtime.

This has the slight disadvantage that ClojureScript functions like print, pr, and a few others, that should not print a newline at the end of their output, do so.

I believe that if instead when Node.js is the runtime, that doo caused it to initialize its print functions using code like shown below, it should fix this minor misbehavior:

(defn enable-nodejs-print! []
  (set! *print-newline* true)
  (set-print-fn!
   (fn [& strings]
     (doseq [s strings]
       (.write js/process.stdout s))))
  (set-print-err-fn!
   (fn [& strings]
     (doseq [s strings]
       (.write js/process.stderr s)))))

I have tested a similar change within ClojureScript itself, with good results for Node.js-based ClojureScript REPLs. https://clojure.atlassian.net/browse/CLJS-3153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant