diff --git a/src/leiningen/try.clj b/src/leiningen/try.clj index f0af1c4..69c3e2d 100644 --- a/src/leiningen/try.clj +++ b/src/leiningen/try.clj @@ -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] @@ -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 diff --git a/test/leiningen/try_test.clj b/test/leiningen/try_test.clj index 89e38f2..47e9fd8 100644 --- a/test/leiningen/try_test.clj +++ b/test/leiningen/try_test.clj @@ -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")))