aboutsummaryrefslogtreecommitdiff
path: root/lux-lein/src
diff options
context:
space:
mode:
authorEduardo Julian2016-12-02 21:40:07 -0400
committerEduardo Julian2016-12-02 21:40:07 -0400
commit9f237c5c5a12dc4aa3b4fbd486586050bf84b2b8 (patch)
tree60517d31082d82cded6d3f0d50e8406695cefa6d /lux-lein/src
parent60d3952d9550cc4d6fd0f5fc8312104b21024799 (diff)
- Fixed a bug that was causing compilation & testing to be done more than necessary.
- Changed the "watch" meta-command to "auto".
Diffstat (limited to 'lux-lein/src')
-rw-r--r--lux-lein/src/leiningen/lux.clj4
-rw-r--r--lux-lein/src/leiningen/lux/builder.clj8
-rw-r--r--lux-lein/src/leiningen/lux/test.clj8
-rw-r--r--lux-lein/src/leiningen/lux/utils.clj12
-rw-r--r--lux-lein/src/leiningen/lux/watch.clj9
5 files changed, 26 insertions, 15 deletions
diff --git a/lux-lein/src/leiningen/lux.clj b/lux-lein/src/leiningen/lux.clj
index 4902d048f..40f39f9d3 100644
--- a/lux-lein/src/leiningen/lux.clj
+++ b/lux-lein/src/leiningen/lux.clj
@@ -23,7 +23,7 @@
"repl"
(&repl/repl project)
- "watch"
+ "auto"
(case (second args)
"build"
(&watch/watch #(&builder/build project) project)
@@ -32,5 +32,5 @@
(&watch/watch #(&test/test project) project))
;; default...
- (println "Commands available: (watch) build, (watch) test, repl"))
+ (println "Commands available: (auto) build, (auto) test, repl"))
)
diff --git a/lux-lein/src/leiningen/lux/builder.clj b/lux-lein/src/leiningen/lux/builder.clj
index 530b61bfe..fcb0562ad 100644
--- a/lux-lein/src/leiningen/lux/builder.clj
+++ b/lux-lein/src/leiningen/lux/builder.clj
@@ -10,9 +10,9 @@
(defn build [project]
(if-let [program-module (get-in project [:lux :program])]
- (do (&utils/run-process (&utils/compile-path project program-module (get project :source-paths (list)))
- nil
- "[BUILD BEGIN]"
- "[BUILD END]")
+ (when (&utils/run-process (&utils/compile-path project program-module (get project :source-paths (list)))
+ nil
+ "[BUILD BEGIN]"
+ "[BUILD END]")
(&packager/package project program-module (get project :resource-paths (list))))
(println "Please provide a program main module in [:lux :program]")))
diff --git a/lux-lein/src/leiningen/lux/test.clj b/lux-lein/src/leiningen/lux/test.clj
index 2a7038904..8567d3ea9 100644
--- a/lux-lein/src/leiningen/lux/test.clj
+++ b/lux-lein/src/leiningen/lux/test.clj
@@ -11,10 +11,10 @@
(defn test [project]
(if-let [tests-module (get-in project [:lux :tests])]
- (do (&utils/run-process (&utils/compile-path project tests-module (concat (:test-paths project) (:source-paths project)))
- nil
- "[BUILD BEGIN]"
- "[BUILD END]")
+ (when (&utils/run-process (&utils/compile-path project tests-module (concat (:test-paths project) (:source-paths project)))
+ nil
+ "[BUILD BEGIN]"
+ "[BUILD END]")
(let [java-cmd (get project :java-cmd "java")
jvm-opts (->> (get project :jvm-opts) (interpose " ") (reduce str ""))
output-package (str (get-in project [:lux :target] &utils/output-dir) "/"
diff --git a/lux-lein/src/leiningen/lux/utils.clj b/lux-lein/src/leiningen/lux/utils.clj
index 6419e9de8..5cc0c4497 100644
--- a/lux-lein/src/leiningen/lux/utils.clj
+++ b/lux-lein/src/leiningen/lux/utils.clj
@@ -86,8 +86,10 @@
(when line
(println line)
(recur (.readLine std-out))))
- (loop [line (.readLine std-err)]
- (when line
- (println line)
- (recur (.readLine std-err))))
- (println post))))
+ (let [first-error-line (.readLine std-err)]
+ (do (loop [line first-error-line]
+ (when line
+ (println line)
+ (recur (.readLine std-err))))
+ (println post)
+ (nil? first-error-line))))))
diff --git a/lux-lein/src/leiningen/lux/watch.clj b/lux-lein/src/leiningen/lux/watch.clj
index d9cae9075..87f8929e1 100644
--- a/lux-lein/src/leiningen/lux/watch.clj
+++ b/lux-lein/src/leiningen/lux/watch.clj
@@ -20,6 +20,14 @@
(->> (.listFiles dir) (mapcat (comp file-tree #(.getAbsolutePath ^File %))) (cons path))
(list))))
+(defn ^:private drain! [^WatchService watcher]
+ (when-let [^WatchKey key (.poll watcher)]
+ (when (and (.isValid key)
+ (not (.isEmpty (.pollEvents key))))
+
+ (.reset key)
+ (recur watcher))))
+
(defn watch [action project]
(let [fs (FileSystems/getDefault)
^WatchService watcher (.newWatchService fs)
@@ -35,6 +43,7 @@
(when (.isValid key)
(.pollEvents key)
(.reset key)
+ (drain! watcher)
(action)))
(Thread/sleep 1000)
(recur))))