|
313 | 313 | ;; Compile
|
314 | 314 | ;; =======
|
315 | 315 |
|
| 316 | +(defprotocol Inputs |
| 317 | + (-paths [this] "Returns the file paths to the source inputs")) |
| 318 | + |
| 319 | +(extend-protocol Inputs |
| 320 | + String |
| 321 | + (-paths [this] [(io/file this)]) |
| 322 | + File |
| 323 | + (-paths [this] [this])) |
| 324 | + |
316 | 325 | (defprotocol Compilable
|
317 | 326 | (-compile [this opts] "Returns one or more IJavaScripts."))
|
318 | 327 |
|
|
1512 | 1521 | ([source opts compiler-env]
|
1513 | 1522 | (watch source opts compiler-env nil))
|
1514 | 1523 | ([source opts compiler-env quit]
|
1515 |
| - (let [opts (cond-> opts |
1516 |
| - (= (:verbose opts :not-found) :not-found) |
1517 |
| - (assoc :verbose true)) |
1518 |
| - path (Paths/get (.toURI (io/file source))) |
1519 |
| - fs (.getFileSystem path) |
1520 |
| - service (.newWatchService fs)] |
| 1524 | + (let [opts (cond-> opts |
| 1525 | + (= (:verbose opts :not-found) :not-found) |
| 1526 | + (assoc :verbose true)) |
| 1527 | + paths (map #(Paths/get (.toURI %)) (-paths source)) |
| 1528 | + path (first paths) |
| 1529 | + fs (.getFileSystem path) |
| 1530 | + srvc (.newWatchService fs)] |
1521 | 1531 | (letfn [(buildf []
|
1522 | 1532 | (try
|
1523 | 1533 | (let [start (System/nanoTime)]
|
|
1537 | 1547 | (preVisitDirectory [_ dir _]
|
1538 | 1548 | (let [^Path dir dir]
|
1539 | 1549 | (. dir
|
1540 |
| - (register service |
| 1550 | + (register srvc |
1541 | 1551 | (into-array [StandardWatchEventKinds/ENTRY_CREATE
|
1542 | 1552 | StandardWatchEventKinds/ENTRY_DELETE
|
1543 | 1553 | StandardWatchEventKinds/ENTRY_MODIFY])
|
|
1552 | 1562 | (println "Building ...")
|
1553 | 1563 | (flush)
|
1554 | 1564 | (buildf)
|
1555 |
| - (println "Watching path:" source) |
1556 |
| - (watch-all path) |
| 1565 | + (println "Watching paths:" (apply str (interpose ", " paths))) |
| 1566 | + (doseq [path paths] |
| 1567 | + (watch-all path)) |
1557 | 1568 | (loop [key nil]
|
1558 | 1569 | (when (and (or (nil? quit) (not @quit))
|
1559 | 1570 | (or (nil? key) (. ^WatchKey key reset)))
|
1560 |
| - (let [key (. service (poll 300 TimeUnit/MILLISECONDS))] |
| 1571 | + (let [key (. srvc (poll 300 TimeUnit/MILLISECONDS))] |
1561 | 1572 | (when (and key
|
1562 | 1573 | (some
|
1563 | 1574 | (fn [^WatchEvent e]
|
|
0 commit comments