Skip to content

Commit 239c9ff

Browse files
committed
Fix exception when config not found (fixes #313)
1 parent 3aa4fdc commit 239c9ff

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cljfmt/src/cljfmt/config.clj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@
5050
([path] (some->> (parent-dirs path) (some find-config-file-in-dir))))
5151

5252
(defn- directory? [path]
53-
(.isDirectory (.getAbsoluteFile (io/file path))))
53+
(some-> path io/file .getAbsoluteFile .isDirectory))
5454

5555
(defn load-config
5656
"Load a configuration merged with a map of sensible defaults. May take
5757
an path to a config file, or to a directory to search. If no argument
5858
is supplied, it uses the current directory. See: [[find-config-file]]."
5959
([] (load-config ""))
6060
([path]
61-
(merge default-config (if (directory? path)
62-
(some-> (find-config-file path) read-config)
63-
(read-config path)))))
61+
(let [path (if (directory? path)
62+
(find-config-file path)
63+
path)]
64+
(merge default-config (some-> path read-config)))))

0 commit comments

Comments
 (0)