Skip to content

Commit

Permalink
Merge pull request #1 from atroche/alistair/checkouts-with-explicit-o…
Browse files Browse the repository at this point in the history
…pt-in
  • Loading branch information
danielcompton authored Mar 26, 2024
2 parents 013ba71 + 23bed09 commit 03a6523
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
22 changes: 13 additions & 9 deletions plugin/src/leiningen/figwheel.clj
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,13 @@
"Get source paths for all of the lein projects in the checkouts directory."
[project]
(let [checkout-project-maps (lproject/read-checkouts project)
checkout-sources (for [co-project checkout-project-maps
source-path (:source-paths co-project)]
;; Make the checkout source path pretty, e.g. checkouts/utils-lib/src
(str (.relativize (.toPath (io/file (:root project))) ;; Note, root of the parent project, not the checkout project
(.toPath (io/file source-path)))))]
parent-project-root-path (.toPath (io/file (:root project)))
checkout-sources (for [co-project checkout-project-maps
source-path-str (:source-paths co-project)
:let [source-path (.toPath (io/file source-path-str))]]
;; Make the checkout source path pretty, e.g. ../utils-lib/src
;; NOTE: this follows the symlink at checkouts/utils-lib
(str (.relativize parent-project-root-path source-path)))]
(distinct checkout-sources)))

(defn map-vals
Expand Down Expand Up @@ -439,8 +441,9 @@

(defn build-once [project build-ids]
(when-not (report-if-bad-build-ids project build-ids)
(let [checkout-sources (checkout-source-paths project)
project (add-source-paths project checkout-sources)]
(let [project (if (:add-checkout-source-paths (figwheel-options project))
(add-source-paths project (checkout-source-paths project))
project)]
(run-build-once
project
(fuzzy-config-from-project project)
Expand All @@ -450,8 +453,9 @@

(defn figwheel-main [project build-ids]
(when-not (report-if-bad-build-ids project build-ids)
(let [checkout-sources (checkout-source-paths project)
project (add-source-paths project checkout-sources)]
(let [project (if (:add-checkout-source-paths (figwheel-options project))
(add-source-paths project (checkout-source-paths project))
project)]
(run-figwheel
project
(-> project fuzzy-config-from-project)
Expand Down
8 changes: 4 additions & 4 deletions plugin/test/leiningen/figwheel_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@
{:id "prod"
:source-paths ["src/cljs" "src/cljc" "prod"]
:resource-paths ["resources"]}]}}
["checkouts/util-lib/src"])
["../util-lib/src"])
{:cljsbuild {:builds [{:id "dev"
:source-paths ["src/cljs" "src/cljc" "dev" "checkouts/util-lib/src"]
:source-paths ["src/cljs" "src/cljc" "dev" "../util-lib/src"]
:resource-paths ["resources"]}
{:id "prod"
:source-paths ["src/cljs" "src/cljc" "prod" "checkouts/util-lib/src"]
:source-paths ["src/cljs" "src/cljc" "prod" "../util-lib/src"]
:resource-paths ["resources"]}]}}))))

(deftest checkout-source-paths-test
Expand All @@ -204,7 +204,7 @@
:output-to "resources/public/js/example.js"
:output-dir "resources/public/js/out"
:optimizations :none}}}}})
["checkouts/utils-lib/src"])))
["../utils-lib/src"])))
(testing "test project with no checkouts"
(is (= (f/checkout-source-paths
{:root (str cwd "/test-resources/test-project-with-no-checkouts")
Expand Down

0 comments on commit 03a6523

Please sign in to comment.