Skip to content

Commit 3aa1951

Browse files
anmonteirodnolen
authored andcommitted
CLJS-1941: cljs.compiler/cljs-files-in shouldn't return .cljc files if a .cljs file exists for the namespace
1 parent f43fabc commit 3aa1951

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/main/clojure/cljs/compiler.cljc

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#?(:clj (:require [cljs.util :as util]
1515
[clojure.java.io :as io]
1616
[clojure.string :as string]
17+
[clojure.set :as set]
1718
[clojure.tools.reader :as reader]
1819
[cljs.env :as env :refer [ensure]]
1920
[cljs.tagged-literals :as tags]
@@ -1446,13 +1447,28 @@
14461447
(defn cljs-files-in
14471448
"Return a sequence of all .cljs and .cljc files in the given directory."
14481449
[dir]
1449-
(filter
1450-
#(let [name (.getName ^File %)]
1451-
(and (or (.endsWith name ".cljs")
1452-
(.endsWith name ".cljc"))
1453-
(not= \. (first name))
1454-
(not (contains? cljs-reserved-file-names name))))
1455-
(file-seq dir))))
1450+
(map io/file
1451+
(reduce
1452+
(fn [m x]
1453+
(if (.endsWith ^String x ".cljs")
1454+
(cond-> (conj m x)
1455+
(contains? m (str (subs x 0 (dec (count x))) "c"))
1456+
(set/difference #{(str (subs x 0 (dec (count x))) "c")}))
1457+
;; ends with .cljc
1458+
(cond-> m
1459+
(not (contains? m (str (subs x 0 (dec (count x))) "s")))
1460+
(conj x))))
1461+
#{}
1462+
(into []
1463+
(comp
1464+
(filter
1465+
#(let [name (.getName ^File %)]
1466+
(and (or (.endsWith name ".cljs")
1467+
(.endsWith name ".cljc"))
1468+
(not= \. (first name))
1469+
(not (contains? cljs-reserved-file-names name)))))
1470+
(map #(.getPath ^File %)))
1471+
(file-seq dir))))))
14561472

14571473
#?(:clj
14581474
(defn compile-root

0 commit comments

Comments
 (0)