Skip to content

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

@jafingerhut

Description

@jafingerhut

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions