/
user.clj
26 lines (23 loc) · 1003 Bytes
/
user.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns leiningen.core.user
"Functions exposing user-level configuration."
(:require [clojure.java.io :as io]))
(defn leiningen-home
"Return full path to the user's Leiningen home directory."
[]
(let [lein-home (System/getenv "LEIN_HOME")
lein-home (or (and lein-home (io/file lein-home))
(io/file (System/getProperty "user.home") ".lein"))]
(.getAbsolutePath (doto lein-home .mkdirs))))
;; TODO: is this still needed now that we have the user profile?
(def init
"Load the user's ~/.lein/init.clj file, if present."
(memoize (fn []
(let [init-file (io/file (leiningen-home) "init.clj")]
(when (.exists init-file)
(try (load-file (.getAbsolutePath init-file))
(catch Exception e
(.printStackTrace e))))))))
(defn profiles []
(let [profiles-file (io/file (leiningen-home) "profiles.clj")]
(if (.exists profiles-file)
(read-string (slurp profiles-file)))))