Skip to content

Commit

Permalink
add :devtools {:repl-pprint true} option
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed May 15, 2018
1 parent eb87961 commit b4491df
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/main/shadow/build/targets/shared.clj
Expand Up @@ -72,7 +72,15 @@
{:keys [build-id]}
build-config

{:keys [ignore-warnings reload-with-state devtools-url before-load before-load-async after-load autoload use-document-host]}
{:keys [ignore-warnings
reload-with-state
devtools-url
before-load
before-load-async
after-load
autoload
use-document-host
repl-pprint]}
(:devtools build-config)]

{"shadow.cljs.devtools.client.env.enabled"
Expand All @@ -93,6 +101,9 @@
"shadow.cljs.devtools.client.env.repl_port"
port

"shadow.cljs.devtools.client.env.repl_pprint"
(true? repl-pprint)

"shadow.cljs.devtools.client.env.ignore_warnings"
(true? ignore-warnings)

Expand Down
21 changes: 16 additions & 5 deletions src/main/shadow/cljs/devtools/client/env.cljs
@@ -1,7 +1,10 @@
(ns shadow.cljs.devtools.client.env
(:require [goog.object :as gobj]
[cljs.tools.reader :as reader]
[clojure.string :as str]))
(:require
[goog.object :as gobj]
[clojure.string :as str]
[cljs.tools.reader :as reader]
[cljs.pprint :refer (pprint)]
))

(defonce client-id (random-uuid))

Expand All @@ -21,6 +24,8 @@

(goog-define repl-port 8200)

(goog-define repl-pprint false)

(goog-define use-document-host true)

(goog-define devtools-url "")
Expand Down Expand Up @@ -53,7 +58,13 @@
(defn files-url []
(str (get-url-base) "/worker/files/" build-id "/" proc-id "/" client-id))

(def repl-print-fn pr-str)
(def repl-print-fn
(if-not repl-pprint
pr-str
(fn repl-pprint [obj]
(with-out-str
(pprint obj)
))))

(defn repl-error [e]
(-> {:type :repl/invoke-error
Expand Down Expand Up @@ -162,7 +173,7 @@
which performs the actual loading of the code (sync)
will call all before/after callbacks in order"
([msg load-code-fn]
(do-js-reload msg load-code-fn (fn [])))
(do-js-reload msg load-code-fn (fn [])))
([{:keys [reload-info] :as msg} load-code-fn complete-fn]
(let [load-tasks
(-> []
Expand Down

0 comments on commit b4491df

Please sign in to comment.