feat #1204: add babashka.config property
This commit is contained in:
parent
92ca3c6501
commit
f9451f5de0
5 changed files with 23 additions and 0 deletions
|
|
@ -5,6 +5,10 @@ For a list of breaking changes, check [here](#breaking-changes).
|
|||
A preview of the next release can be installed from
|
||||
[babashka-dev-builds](https://github.com/babashka/babashka-dev-builds).
|
||||
|
||||
## Unreleased
|
||||
|
||||
- [#1204](https://github.com/babashka/babashka/issues/1204) add property `babashka.config` to reflect `bb.edn` location ([@mknoszlig](https://github.com/mknoszlig))
|
||||
|
||||
## 0.7.7 (2022-03-04)
|
||||
|
||||
### New
|
||||
|
|
|
|||
|
|
@ -933,6 +933,8 @@ Use bb run --help to show this help output.
|
|||
bb-edn-file (or config
|
||||
"bb.edn")
|
||||
bb-edn (when (fs/exists? bb-edn-file)
|
||||
(System/setProperty "babashka.config"
|
||||
(.getAbsolutePath (io/file bb-edn-file)))
|
||||
(let [raw-string (slurp bb-edn-file)
|
||||
edn (edn/read-string raw-string)
|
||||
edn (assoc edn
|
||||
|
|
|
|||
9
test-resources/babashka/config_property.clj
Normal file
9
test-resources/babashka/config_property.clj
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(ns babashka.config-property
|
||||
(:require [babashka.fs :as fs]))
|
||||
|
||||
(def prop (System/getProperty "babashka.config"))
|
||||
|
||||
(prn (boolean (seq prop)))
|
||||
|
||||
(when prop
|
||||
(prn (fs/exists? (System/getProperty "babashka.config"))))
|
||||
|
|
@ -603,6 +603,13 @@
|
|||
(testing "bb executes the empty expression and doesn't start a REPL"
|
||||
(is (working? (test-utils/bb nil "-e" "")))))
|
||||
|
||||
(deftest config-property-test
|
||||
(is (= "true\ntrue\n"
|
||||
(test-utils/with-config {:tasks {}}
|
||||
(test-utils/bb nil (.getPath (io/file "test-resources" "babashka" "config_property.clj"))))))
|
||||
(is (= "false\n"
|
||||
(test-utils/bb nil (.getPath (io/file "test-resources" "babashka" "config_property.clj"))))))
|
||||
|
||||
(deftest file-property-test
|
||||
(is (= "true\nfalse\n"
|
||||
(test-utils/bb nil (.getPath (io/file "test-resources" "babashka" "file_property1.clj")))))
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
(reset! cp/cp-state nil)
|
||||
(reset! main/env {})
|
||||
(vreset! common/bb-edn nil)
|
||||
(System/clearProperty "babashka.config")
|
||||
(let [args (cond-> args *bb-edn-path*
|
||||
(->> (list* "--config" *bb-edn-path* "--deps-root" ".")))
|
||||
os (java.io.StringWriter.)
|
||||
|
|
|
|||
Loading…
Reference in a new issue