Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2018 08:00
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save theronic/827c694ac2247a5fbc3afde41780931f to your computer and use it in GitHub Desktop.
Convert Clojure project.clj :dependencies to deps.edn style
; using Clojure 1.9
(require '[clojure.pprint :as pprint])
(defn xform-dep [[lib version & korks]]
(let [args (into {} (apply hash-map korks))]
[lib (merge {:mvn/version version} args)]))
(defn xform-deps
"deps.edn utility function by @theronic 2018-02-28
Transforms a collection of project.clj :dependencies to deps.edn style
'[[org.clojure/clojurescript \"1.9.946\" :exclusions [org.clojure/clojure]]
=> {:deps {org.clojure/clojurescript {:mvn/version \" 1.9.946\", :exclusions [org.clojure/clojure]}}
(binding [*print-namespace-maps* false
pprint/*print-right-margin* 300]
(pprint/pprint (into {} (map xform-dep coll)))))
(xform-deps '[[org.clojure/clojure "1.9.0"]
[org.clojure/clojurescript "1.9.946" :exclusions [org.clojure/clojure]]
[pandeiro/boot-http "0.8.3" :scope "test"]])
; => {org.clojure/clojure {:mvn/version "1.9.0"}
; org.clojure/clojurescript {:mvn/version "1.9.946", :exclusions [org.clojure/clojure]}
; pandeiro/boot-http {:mvn/version "0.8.3", :scope "test"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment