Fix #1586: warn when config file doesn't exist and debug is enabled

This commit is contained in:
Michiel Borkent 2024-01-09 14:36:25 +01:00
parent d85c86af2c
commit 2166c42de2
2 changed files with 7 additions and 2 deletions

View file

@ -15,6 +15,7 @@ A preview of the next release can be installed from
- [#1646](https://github.com/babashka/babashka/issues/1646): command-line-args are dropped when file exists with same name
- [#1645](https://github.com/babashka/babashka/issues/1645): Support for clojure.lang.LongRange
- [#1652](https://github.com/babashka/babashka/issues/1652): allow `bb.edn` to be empty
- [#1586](https://github.com/babashka/babashka/issues/1586): warn when config file doesn't exist and `--debug` is enabled
## 1.3.186 (2023-11-02)

View file

@ -1145,14 +1145,18 @@ Use bb run --help to show this help output.
args)
[args opts] (parse-global-opts args)
;; TODO: drop jar file from opts
[args {:keys [jar file config merge-deps] :as opts}]
[args {:keys [jar file config merge-deps debug] :as opts}]
(if-not (or (:file opts)
(:jar opts))
(parse-file-opt args opts)
[args opts])
abs-path #(-> % io/file .getAbsolutePath)
config (cond
config (when (fs/exists? config) (abs-path config))
config (if (fs/exists? config) (abs-path config)
(when debug
(binding [*out* *err*]
(println "[babashka] WARNING: config file does not exist:" config))
nil))
jar (some-> [jar] cp/new-loader (cp/resource "META-INF/bb.edn") .toString)
:else (if (and file (fs/exists? file))
;; file relative to bb.edn