Skip to content

Commit

Permalink
Don't clobber any existing :custom-init configuration
Browse files Browse the repository at this point in the history
Leiningen doesn't know how to merge this option - see technomancy/leiningen#878.
Instead, use ^:replace metadata to overwrite it completely with a form that
evaluates any existing value before evaluating our init code.
  • Loading branch information
cichli committed Feb 16, 2019
1 parent d6f0923 commit dc6fb8c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/whidbey/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@

(defn- whidbey-profile
"Constructs a profile map for enabling the repl hooks."
[version options]
(->
`{:dependencies [[mvxcvi/whidbey ~(or version "RELEASE")]]
:repl-options {:custom-init (do (require 'whidbey.repl)
(whidbey.repl/init! ~options))
;; :printer is nrepl 0.5.x only
:nrepl-context {:interactive-eval {:printer whidbey.repl/render-str}}}}
(vary-meta assoc :repl true)))
[project]
(let [version (find-plugin-version project 'mvxcvi/whidbey)
options (:whidbey project)
custom-init (get-in project [:repl-options :custom-init])]
(-> `{:dependencies [[mvxcvi/whidbey ~(or version "RELEASE")]]
:repl-options {:custom-init ^:replace (do ~custom-init
(require 'whidbey.repl)
(whidbey.repl/init! ~options))
;; :printer is nrepl 0.5.x only
:nrepl-context {:interactive-eval {:printer whidbey.repl/render-str}}}}
(vary-meta assoc :repl true))))


(defn repl-pprint
Expand All @@ -35,7 +38,5 @@
[project]
(if (:whidbey/repl (:profiles project))
project
(let [options (:whidbey project)
version (find-plugin-version project 'mvxcvi/whidbey)
profile (whidbey-profile version options)]
(let [profile (whidbey-profile project)]
(project/add-profiles project {:whidbey/repl profile}))))

0 comments on commit dc6fb8c

Please sign in to comment.