@@ -145,20 +145,36 @@ classpath. Classpath-relative paths have prefix of @ or @/")
145
145
[cfg value]
146
146
(assoc-in cfg [:options :verbose ] (= value " true" )))
147
147
148
+ (defn- validate-watch-paths [[path :as paths]]
149
+ (when (or (nil? path)
150
+ (and (not (.exists (io/file path)))
151
+ (or (string/blank? path)
152
+ (string/starts-with? path " -" ))))
153
+ (throw
154
+ (ex-info
155
+ (str " Missing watch path(s)" )
156
+ {:cljs.main/error :invalid-arg })))
157
+ (when-let [non-existent (seq (remove #(.exists (io/file %)) paths))]
158
+ (throw
159
+ (ex-info
160
+ (if (== 1 (count non-existent))
161
+ (str " Watch path "
162
+ (first non-existent)
163
+ " does not exist" )
164
+ (str " Watch paths "
165
+ (string/join " , " (butlast non-existent))
166
+ " and "
167
+ (last non-existent)
168
+ " does not exist" ))
169
+ {:cljs.main/error :invalid-arg }))))
170
+
148
171
(defn- watch-opt
149
- [cfg path]
150
- (when-not (.exists (io/file path))
151
- (if (or (string/starts-with? path " -" )
152
- (string/blank? path))
153
- (throw
154
- (ex-info
155
- (str " Missing watch path" )
156
- {:cljs.main/error :invalid-arg }))
157
- (throw
158
- (ex-info
159
- (str " Watch path " path " does not exist" )
160
- {:cljs.main/error :invalid-arg }))))
161
- (assoc-in cfg [:options :watch ] path))
172
+ [cfg paths]
173
+ (let [paths (util/split-paths paths)]
174
+ (validate-watch-paths paths)
175
+ (assoc-in cfg [:options :watch ] (cond-> paths
176
+ (== 1 (count paths))
177
+ first))))
162
178
163
179
(defn- optimize-opt
164
180
[cfg level]
@@ -454,7 +470,9 @@ present"
454
470
(not (:output-dir opts))
455
471
(assoc :output-dir " out" )
456
472
(not (contains? opts :aot-cache ))
457
- (assoc :aot-cache true )))
473
+ (assoc :aot-cache true )
474
+ (sequential? (:watch opts))
475
+ (update :watch cljs.closure/compilable-input-paths)))
458
476
convey (into [:output-dir ] repl/known-repl-opts)
459
477
cfg (update cfg :options merge (select-keys opts convey))
460
478
source (when (and (= :none (:optimizations opts :none )) main-ns)
@@ -533,8 +551,10 @@ present"
533
551
" will be used to set ClojureScript compiler "
534
552
" options" ) }
535
553
[" -w" " --watch" ] {:group ::compile :fn watch-opt
536
- :arg " path"
537
- :doc " Continuously build, only effective with the --compile main option" }
554
+ :arg " paths"
555
+ :doc (str " Continuously build, only effective with the "
556
+ " --compile main option. Specifies a system-dependent "
557
+ " path-separated list of directories to watch." )}
538
558
[" -o" " --output-to" ] {:group ::compile :fn output-to-opt
539
559
:arg " file"
540
560
:doc " Set the output compiled file" }
0 commit comments