Skip to content

Commit 1eb36c7

Browse files
committed
Add clojure.tools.deps.edn/user-config-dir function
1 parent 39394fc commit 1eb36c7

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
===========
33

4+
* next
5+
* Add clojure.tools.deps.edn/user-config-dir function
46
* 0.9.27 on May 13, 2026
57
* Update to Clojure 1.12.5
68
* 0.9.22 on Feb 9, 2026

src/main/clojure/clojure/tools/deps/edn.clj

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,24 @@
145145
(let [url (jio/resource "clojure/tools/deps/deps.edn")]
146146
(read-edn (BufferedReader. (InputStreamReader. (.openStream url))))))
147147

148-
(defn user-deps-path
149-
"Use the same logic as clj to calculate the location of the user deps.edn.
150-
Note that it's possible no file may exist at this location."
148+
(defn user-config-dir
149+
"Use the same logic as clj to calculate the location of the user config dir.
150+
Note that it's possible no dir may exist at this location.
151+
Return path as string."
151152
[]
152153
(let [config-env (System/getenv "CLJ_CONFIG")
153154
xdg-env (System/getenv "XDG_CONFIG_HOME")
154-
home (System/getProperty "user.home")
155-
config-dir (cond config-env config-env
156-
xdg-env (str xdg-env File/separator "clojure")
157-
:else (str home File/separator ".clojure"))]
158-
(str config-dir File/separator "deps.edn")))
155+
home (System/getProperty "user.home")]
156+
(cond config-env config-env
157+
xdg-env (str xdg-env File/separator "clojure")
158+
:else (str home File/separator ".clojure"))))
159+
160+
(defn user-deps-path
161+
"Use the same logic as clj to calculate the location of the user deps.edn.
162+
Note that it's possible no file may exist at this location.
163+
Returns path as string."
164+
[]
165+
(str (user-config-dir) File/separator "deps.edn"))
159166

160167
(defn user-deps
161168
"Calculate the user deps.edn per user-deps-path, read and

0 commit comments

Comments
 (0)