Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add system property babashka.version which contains current bb version #479

Closed
borkdude opened this issue Jun 15, 2020 · 3 comments
Closed

Comments

@borkdude
Copy link
Collaborator

borkdude commented Jun 15, 2020

A use case it for people to check a minimum babashka.version. Comparing strings isn't very ergonomic. Should we solve it a different way than with System properties? How can we still preserve compatibility with Clojure by not introducing non-custom vars?

@borkdude
Copy link
Collaborator Author

borkdude commented Jun 17, 2020

@jeroenvandijk Would this work well enough?

(require '[clojure.string :as str])

(def babashka-version (System/getProperty "babashka.version"))
;; e.g. 0.1.3-SNAPSHOT

(defn compare-version [v]
  (nat-int? (compare
             (mapv #(Integer. %)
                   (take 3 (str/split babashka-version  #"[\.\-]"))) v)))

(prn (compare-version [0 1 2])) ;; true
(prn (compare-version [0 1 3])) ;; true
(prn (compare-version [0 1 4])) ;; false

@borkdude
Copy link
Collaborator Author

@jeroenvandijk
Copy link
Contributor

@borkdude Yeah I think that's perfect for what I had in mind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants