Skip to content

Commit 657dd13

Browse files
aibaexpez
authored andcommitted
Preserve npm string-style requires for cljr-clean-ns
bugfix
1 parent ef40b11 commit 657dd13

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/refactor_nrepl/ns/rebuild.clj

+11-5
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,22 @@
9797
:all
9898
(sort dependency-comparator referred)))
9999

100+
(defn- type-preserving [f x]
101+
(when x
102+
(when-let [r (f x)]
103+
(cond
104+
(string? x) (str r)
105+
(symbol? x) (symbol r)))))
106+
100107
(defn- ns-prefix
101108
"Extracts the prefix from a libspec."
102109
[{:keys [ns]}]
103-
(if (prefix ns)
104-
(symbol (prefix ns))
105-
:none))
110+
(or (type-preserving prefix ns)
111+
:none))
106112

107113
(defn- ns-suffix
108114
[{:keys [ns]}]
109-
(-> ns suffix symbol))
115+
(type-preserving suffix ns))
110116

111117
(defn- by-prefix
112118
[libspecs]
@@ -139,7 +145,7 @@
139145
[libspecs]
140146
(vec
141147
(for [libspec libspecs]
142-
(create-libspec (update-in libspec [:ns] #(-> % suffix symbol))))))
148+
(create-libspec (assoc libspec :ns (ns-suffix libspec))))))
143149

144150
(defn- create-libspec-vectors-with-prefix
145151
[libspecs]

0 commit comments

Comments
 (0)