Allow custom kibit rules
project.clj will need to have following entry :kibit {:rules (merge kibit.rules/rule-map {:ctrl test/rules}) :source-paths ["rules"]} All namespaces found in source-paths dir will be required during kibit run. Update kibit version in project.clj and 'kibit-project'
This commit is contained in:
parent
df4fa32160
commit
ad64732baa
2 changed files with 22 additions and 10 deletions
|
@ -3,5 +3,6 @@
|
|||
:url "https://github.com/jonase/lein-kibit"
|
||||
:license {:name "Eclipse Public License"
|
||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||
:dependencies [[jonase/kibit "0.1.2"]]
|
||||
:dependencies [[jonase/kibit "0.1.2"]
|
||||
[org.clojure/tools.namespace "0.2.11"]]
|
||||
:eval-in-leiningen true)
|
||||
|
|
|
@ -1,17 +1,28 @@
|
|||
(ns leiningen.kibit
|
||||
(:require [leiningen.core.eval :refer [eval-in-project]]))
|
||||
(:require [leiningen.core.eval :refer [eval-in-project]]
|
||||
[clojure.tools.namespace.find :refer [find-namespaces]])
|
||||
(:import [java.io File]))
|
||||
|
||||
|
||||
(defn ^:no-project-needed kibit
|
||||
[project & args]
|
||||
(let [kibit-project '{:dependencies [[jonase/kibit "0.1.2"]]}
|
||||
paths (seq (disj (set (concat
|
||||
(:source-paths project)
|
||||
(let [src-paths (get-in project [:kibit :source-paths] ["rules"])
|
||||
kibit-project `{:dependencies [[jonase/kibit "0.1.2"]]
|
||||
:source-paths ~src-paths}
|
||||
paths (seq (disj (set (concat (:source-paths project)
|
||||
[(:source-path project)]
|
||||
(mapcat :source-paths (get-in project [:cljsbuild :builds]))
|
||||
(mapcat :source-paths (get-in project [:cljx :builds]))))
|
||||
nil))
|
||||
src `(kibit.driver/external-run '~paths ~@args)
|
||||
req '(require 'kibit.driver)]
|
||||
rules (get-in project [:kibit :rules])
|
||||
src `(kibit.driver/external-run '~paths
|
||||
(when ~rules
|
||||
(apply concat (vals ~rules)))
|
||||
~@args)
|
||||
ns-xs (mapcat identity (map #(find-namespaces [(File. %)]) src-paths))
|
||||
req `(do (require 'kibit.driver)
|
||||
(doseq [n# '~ns-xs]
|
||||
(require n#)))]
|
||||
(try (eval-in-project kibit-project src req)
|
||||
(catch Exception e
|
||||
(throw (ex-info "" {:exit-code 1}))))))
|
||||
|
|
Loading…
Reference in a new issue