Skip to content

Commit

Permalink
cljfmt: support standalone cli
Browse files Browse the repository at this point in the history
  • Loading branch information
totakke committed Feb 24, 2025
1 parent b56de96 commit 93834f6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:cljfmt
{:disabled? false
:version "0.13.0" ; default "RELEASE"
:clojure {:command-options ["--indents" "/path/to/indentation.edn"]}}
:command-options ["--indents" "/path/to/indentation.edn"]}

:cljstyle
{:disabled? false}
Expand Down
16 changes: 15 additions & 1 deletion src/bosslint/linter/cljfmt.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@

(def ^:private cljfmt-artifact "dev.weavejester/cljfmt")

(defn- cljfmt-cli
[files conf]
(let [args (concat ["cljfmt" "check"]
(:command-options conf)
(map :absolute-path files))]
(case (apply process/run args)
0 :success
1 :warning
:error)))

(defn- cljfmt-clojure
[files conf]
(let [version (or (:version conf) "RELEASE")
args (concat ["clojure"
"-Sdeps" (format "{:deps {%s {:mvn/version \"%s\"}}}"
cljfmt-artifact version)
"-M" "-m" "cljfmt.main" "check"]
(:command-options (:clojure conf))
(or (:command-options conf)
(:command-options (:clojure conf)))
(map :absolute-path files))]
(case (apply process/run args)
0 :success
Expand Down Expand Up @@ -40,6 +51,9 @@

(lint [files conf]
(if-let [f (cond
(process/command-exists? "cljfmt")
cljfmt-cli

(and (linter/leiningen-project?)
(process/command-exists? "lein"))
cljfmt-lein
Expand Down

0 comments on commit 93834f6

Please sign in to comment.