Skip to content

Commit 66f6bc5

Browse files
committed
add :bundle-cmd
1 parent 309304a commit 66f6bc5

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
[cljs.env :as env]
1717
[cljs.js-deps :as deps]
1818
[clojure.java.io :as io]
19+
[clojure.java.shell :as sh]
1920
[clojure.reflect]
2021
[clojure.set :as set]
2122
[clojure.string :as string]
@@ -205,7 +206,7 @@
205206
:watch :watch-error-fn :watch-fn :install-deps :process-shim :rename-prefix :rename-prefix-namespace
206207
:closure-variable-map-in :closure-property-map-in :closure-variable-map-out :closure-property-map-out
207208
:stable-names :ignore-js-module-exts :opts-cache :aot-cache :elide-strict :fingerprint :spec-skip-macros
208-
:nodejs-rt :target-fn :deps-cmd})
209+
:nodejs-rt :target-fn :deps-cmd :bundle-cmd})
209210

210211
(def string->charset
211212
{"iso-8859-1" StandardCharsets/ISO_8859_1
@@ -3169,6 +3170,32 @@
31693170
(output-one-file opts)))))
31703171
(apply output-unoptimized opts js-sources))]
31713172
(output-bootstrap opts)
3173+
(when (bundle? opts)
3174+
(when-let [cmd (and (= :none optim)
3175+
(get-in opts [:bundle-cmd :none]))]
3176+
(let [{:keys [exit out]}
3177+
(try
3178+
(apply sh/sh cmd)
3179+
(catch Throwable t
3180+
(throw
3181+
(ex-info ":build-cmd :none failed"
3182+
{:cmd cmd} t))))]
3183+
(when-not (== 0 exit)
3184+
(throw
3185+
(ex-info ":bundle-cmd :none failed"
3186+
{:cmd cmd :exit-code exit :std-out out})))))
3187+
(when-let [cmd (and (not= :none optim)
3188+
(get-in opts [:bundle-cmd :default]))]
3189+
(let [{:keys [exit out]}
3190+
(try
3191+
(apply sh/sh cmd)
3192+
(catch Throwable t
3193+
(ex-info ":build-cmd :default failed"
3194+
{:cmd cmd} t)))]
3195+
(when-not (== 0 exit)
3196+
(throw
3197+
(ex-info ":bundle-cmd :default failed"
3198+
{:cmd cmd :exit-code exit :std-out out}))))))
31723199
ret))))))
31733200

31743201
(comment

0 commit comments

Comments
 (0)