Skip to content

Commit

Permalink
Make assert-min-encore-version a macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Sep 27, 2024
1 parent 06898f0 commit 493eeda
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/taoensso/encore.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -2181,20 +2181,21 @@

(comment [(parse-version "40.32.34.8-foo") (parse-version 10.3)])

(defn assert-min-encore-version
"Version check for dependency conflicts, etc."
[min-version]
(let [[^long xc ^long yc ^long zc] encore-version
[ xm ym zm] (if (vector? min-version) min-version (:version (parse-version min-version)))
[^long xm ^long ym ^long zm] (mapv #(or % 0) [xm ym zm])]

(when-not (or (> xc xm) (and (= xc xm) (or (> yc ym) (and (= yc ym) (>= zc zm)))))
(throw
(ex-info "Insufficient `com.taoensso/encore` version, you may have a dependency conflict: see `https://www.taoensso.com/dependency-conflicts` for solutions."
{:min-version (str/join "." [xm ym zm])
:your-version (str/join "." [xc yc zc])})))))

(comment (assert-min-encore-version 3.10))
#?(:clj
(defmacro assert-min-encore-version
"Version check for dependency conflicts, etc."
[min-version]
(let [[^long xc ^long yc ^long zc] encore-version
[ xm ym zm] (if (vector? min-version) min-version (:version (parse-version min-version)))
[^long xm ^long ym ^long zm] (mapv #(or % 0) [xm ym zm])]

(when-not (or (> xc xm) (and (= xc xm) (or (> yc ym) (and (= yc ym) (>= zc zm)))))
(throw
(ex-info "Insufficient `com.taoensso/encore` version, you may have a dependency conflict: see `https://www.taoensso.com/dependency-conflicts` for solutions."
{:min-version (str/join "." [xm ym zm])
:your-version (str/join "." [xc yc zc])}))))))

(comment (assert-min-encore-version [3 10]))

;;;; Collections

Expand Down

0 comments on commit 493eeda

Please sign in to comment.