/
lein_pretty.clj
35 lines (31 loc) · 1.29 KB
/
lein_pretty.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(ns io.aviso.lein-pretty
"A plugin for Leiningen that automatically enables pretty printing."
{:added "0.1.19"}
(:require
[leiningen.core.main :as main]))
;; Ugly! But necessary since middleware gets invoked more than once for some unknown reason.
(def ^:private print-warning
(delay (main/warn "Unable to enable pretty exception reporting, as io.aviso/pretty is not a project dependency.")))
(defn inject
"Adds the :injections that enable Pretty inside the project's process, by executing
`(io.aviso.repl/install-pretty-exceptions)`.
This is enabled by adding `io.aviso.lein-pretty/inject` to the :middleware of the project.clj."
[project]
(if (contains? (->> project
:dependencies
(map first)
set)
'io.aviso/pretty)
(update-in project [:injections]
conj
`(try
(require 'io.aviso.repl)
(let [install# (resolve 'io.aviso.repl/install-pretty-exceptions)]
(install#))
(catch Throwable t#
(println "Error loading io.aviso/pretty support:"
(or (.getMessage t#)
(type t#))))))
(do
@print-warning
project)))