Skip to content

Commit c205921

Browse files
committed
Allow configuration of the node modules dependency tool
Add :deps-cmd compiler option. Add --deps-cmd cljs.main flag. Update cljs.closure/maybe-install-node-deps! to respect :deps-cmd
1 parent 77c7cab commit c205921

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/main/clojure/cljs/cli.clj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ classpath. Classpath-relative paths have prefix of @ or @/")
185185
[cfg path]
186186
(assoc-in cfg [:options :output-to] path))
187187

188+
(defn- deps-cmd-opt
189+
[cfg deps-cmd]
190+
(assoc-in cfg [:options :deps-cmd] deps-cmd))
191+
188192
(defn- target-opt
189193
[cfg target]
190194
(let [target (if (= "node" target) "nodejs" target)]
@@ -600,6 +604,9 @@ present"
600604
["-o" "--output-to"] {:group ::compile :fn output-to-opt
601605
:arg "file"
602606
:doc "Set the output compiled file"}
607+
["--deps-cmd"] {:group ::compile :fn deps-cmd-opt
608+
:arg "string"
609+
:doc "Set the node dependency manager. Only npm or yarn supported"}
603610
["-O" "--optimizations"] {:group ::compile :fn optimize-opt
604611
:arg "level"
605612
:doc

src/main/clojure/cljs/closure.clj

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
:watch :watch-error-fn :watch-fn :install-deps :process-shim :rename-prefix :rename-prefix-namespace
206206
:closure-variable-map-in :closure-property-map-in :closure-variable-map-out :closure-property-map-out
207207
:stable-names :ignore-js-module-exts :opts-cache :aot-cache :elide-strict :fingerprint :spec-skip-macros
208-
:nodejs-rt :target-fn})
208+
:nodejs-rt :target-fn :deps-cmd})
209209

210210
(def string->charset
211211
{"iso-8859-1" StandardCharsets/ISO_8859_1
@@ -2539,7 +2539,7 @@
25392539
(recur buf)))))
25402540

25412541
(defn maybe-install-node-deps!
2542-
[{:keys [npm-deps verbose] :as opts}]
2542+
[{:keys [deps-cmd npm-deps verbose] :or {deps-cmd "npm"} :as opts}]
25432543
(let [npm-deps (merge npm-deps (compute-upstream-npm-deps opts))]
25442544
(when-not (empty? npm-deps)
25452545
(let [pkg-json (io/file "package.json")]
@@ -2548,7 +2548,10 @@
25482548
(when-not (.exists pkg-json)
25492549
(spit pkg-json "{}"))
25502550
(let [proc (-> (ProcessBuilder.
2551-
(into (cond->> ["npm" "install" "@cljs-oss/module-deps"]
2551+
(into (cond->>
2552+
[deps-cmd
2553+
({"npm" "install" "yarn" "add"} deps-cmd)
2554+
"@cljs-oss/module-deps"]
25522555
util/windows? (into ["cmd" "/c"]))
25532556
(map (fn [[dep version]] (str (name dep) "@" version)))
25542557
npm-deps))

0 commit comments

Comments
 (0)