From 1912b921dff6d9f43b325d2e51496aa8df634eb5 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 27 Dec 2021 21:31:13 +0100 Subject: [PATCH] Fixes for issue reported by @thiagokokada --- src/babashka/impl/deps.clj | 12 +++++------- src/babashka/main.clj | 12 +++++++----- test/babashka/bb_edn_test.clj | 3 +-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/babashka/impl/deps.clj b/src/babashka/impl/deps.clj index ccccf2b9..65c40860 100644 --- a/src/babashka/impl/deps.clj +++ b/src/babashka/impl/deps.clj @@ -60,18 +60,16 @@ ([deps-map] (add-deps deps-map nil)) ([deps-map {:keys [:aliases :env :extra-env :force]}] (when-let [paths (:paths deps-map)] - (let [paths (let [deps-root (:deps-root @bb-edn) - deps-root (fs/absolutize deps-root) - ;; cwd (fs/absolutize ".") - ;; rel (fs/relativize cwd f) - paths (mapv #(str (fs/file deps-root %)) paths)] + (let [paths (if-let [deps-root (:deps-root @bb-edn)] + (let [deps-root (fs/absolutize deps-root) + paths (mapv #(str (fs/file deps-root %)) paths)] + paths) paths)] (cp/add-classpath (str/join cp/path-sep paths)))) (when-let [deps-map (not-empty (dissoc deps-map ;; paths are added manually above + ;; extra-paths are added as :paths in tasks :paths - ;; extra-paths are transformed to :deps in task handling - :extra-paths :tasks :raw :min-bb-version))] (binding [*print-namespace-maps* false] (let [deps-map (assoc-in deps-map [:aliases :org.babashka/defaults] diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 5428ebf0..d77ce979 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -920,17 +920,19 @@ Use bb run --help to show this help output. (defn main [& args] (let [[args global-opts] (parse-global-opts args) - bb-edn-file (or (:config global-opts) + config (:config global-opts) + bb-edn-file (or config "bb.edn") bb-edn (when (fs/exists? bb-edn-file) (let [raw-string (slurp bb-edn-file) edn (edn/read-string raw-string) edn (assoc edn :raw raw-string - :file bb-edn-file - :deps-root - (or (:deps-root global-opts) - (str (fs/parent bb-edn-file))))] + :file bb-edn-file) + edn (if-let [deps-root (or (:deps-root global-opts) + (some-> config fs/parent))] + (assoc edn :deps-root deps-root) + edn)] (vreset! common/bb-edn edn))) min-bb-version (:min-bb-version bb-edn)] (when min-bb-version diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index fc0328e6..e585ece4 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -7,8 +7,7 @@ [babashka.test-utils :as test-utils] [clojure.edn :as edn] [clojure.string :as str] - [clojure.test :as test :refer [deftest is testing]] - [sci.core :as sci])) + [clojure.test :as test :refer [deftest is testing]])) (defn bb [& args] (let [args (map str args)