bensu / doo

doo is a library and lein plugin to run cljs.test on different js environments.
Eclipse Public License 1.0
324 stars 63 forks source link

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

Open jafingerhut opened 4 years ago

jafingerhut commented 4 years ago

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