From d85c86af2c82f05d845c802af36699a5c443e8be Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 9 Jan 2024 12:26:20 +0100 Subject: [PATCH] Fix #1652: allow bb.edn to be empty --- CHANGELOG.md | 1 + fs | 2 +- src/babashka/main.clj | 2 +- test/babashka/bb_edn_test.clj | 3 +++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 467c66ee..b7383c3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ A preview of the next release can be installed from - Allow `catch` to be used as var name - [#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 ## 1.3.186 (2023-11-02) diff --git a/fs b/fs index 40fcceb2..aed36f10 160000 --- a/fs +++ b/fs @@ -1 +1 @@ -Subproject commit 40fcceb22b9728fee1c2ce0e58e390e5fe23f2cd +Subproject commit aed36f10bda703018a30f8971ebe2c1c3db76726 diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 49bc7aad..dff681ae 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -1113,7 +1113,7 @@ Use bb run --help to show this help output. (>= patch-current patch-min))))))) (defn read-bb-edn [string] - (try (edn/read-string {:default tagged-literal} string) + (try (edn/read-string {:default tagged-literal :eof nil} string) (catch java.lang.RuntimeException e (if (re-find #"No dispatch macro for: \"" (.getMessage e)) (throw (ex-info "Invalid regex literal found in EDN config, use re-pattern instead" {})) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index 24ab1a1d..96852475 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -533,6 +533,9 @@ even more stuff here\" (deftest non-existing-tasks-in-run-gives-exit-code-1 (is (thrown? Exception (bb "-Sdeps" "{:tasks {foo {:task (run (quote bar))}}}" "foo")))) +(deftest empty-bb-edn-test + (is (= 6 (bb "-Sdeps" "" "-e" "(+ 1 2 3)")))) + (deftest warning-on-override-task (when-not tu/native? (binding [*out* *err*]