Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/leiningen/try.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
(fn [args]
(lazy-convert args))))

(defn- disable-pedantic
"Reduce `:pedantic?` level to `:warn` if `:abort` is given, maintain type to
not cause unnecessary warnings."
[{:keys [pedantic?] :as project}]
(if (and pedantic? (= (name pedantic?) "abort"))
(->> (condp #(% %2) pedantic?
string? "warn"
symbol? 'warn
:warn)
(assoc-in project [:profiles :try :pedantic?]))
project))

(defn- add-try-deps
"Add list of try-dependencies to project."
[deps project]
Expand All @@ -60,6 +72,7 @@
"Resolve try-dependencies and start REPL."
[project]
(let [project (-> project
disable-pedantic
add-reload-data-readers-injection
;; Necessary to update project map metadata Lein uses internally
prj/project-with-profiles
Expand Down
14 changes: 14 additions & 0 deletions test/leiningen/try_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@
:profiles {:try {:dependencies [[:a :b]]}}})
{:dependencies [[:c :d]]
:profiles {:try {:dependencies [[:a :b] [:e :f]]}}}))))

(deftest disable-pedantic-test
(let [disable-pedantic #'leiningen.try/disable-pedantic]
(are [project] (= (disable-pedantic project) project)
{}
{:pedantic? :warn}
{:pedantic? :none}
{:pedantic? :something-else})
(are [pedantic? result] (= (get-in (disable-pedantic {:pedantic? pedantic?})
[:profiles :try :pedantic?])
result)
:abort :warn
'abort 'warn
"abort" "warn")))