 (def js-spawn (aget child-proc "spawn"))
 
 ;;------------------------------------------------------------------------------
-;; Paser Compiler Output
+;; Determine Compiler Output Line Type
 ;;------------------------------------------------------------------------------
 
 ;; NOTE: this probably belongs in it's own library or emitted as EDN from the
 ;; compiler itself
 ;; we can get by with regex and duct tape for now ;)
 
-(defn- start-error-line? [s]
-  (and (.test #"Compiling " s)
-       (.test #"failed\." s)))
-
-(defn- end-error-line? [s]
-  (.test #"Subprocess failed" s))
-
-(def end-error-msg (str "***END ERROR***" (uuid)))
-
-(defn- end-error-line? [s]
+(defn- red-line? [s]
+  (.test #"\[31m" s))
+
+(def ^:private stopped-signal (str "*** OUTPUT STOPPED *** " (uuid)))
+
+(defn- end-line? [s]
   (or (.test #"Subprocess failed" s)
-      (= s end-error-msg)))
+      (= s stopped-signal)))
+
+(defn- success-line? [s]
+  (and (.test #"Successfully compiled" s)
+       (.test #"seconds\." s)))
+
+(defn- warning-line? [s]
+  (.test #"^WARNING: " s))
 
 (defn- start-line? [s]
   (and (.test #"Compiling " s)
        (.test #"]\.\.\.$" s)))
 
-(defn- success-line? [s]
-  (and (.test #"Successfully compiled" s)
-       (.test #"seconds\." s)))
-
-(defn- warning-line? [s]
-  (.test #"^WARNING: " s))
-
-(defn- determine-output-type
+(defn- determine-line-type
   "Returns the type of line output from the compiler.
    nil if we do not recognize the line or don't care what it is"
   [s]
   (cond
-    (start-error-line? s) :start-error
-    (end-error-line? s) :end-error
+    (red-line? s) :error
+    (end-line? s) :end-output
     (success-line? s) :success
     (warning-line? s) :warning
     (start-line? s) :start
     :else nil))
+
+;;------------------------------------------------------------------------------
+;; Extract Info From Lines
+;;------------------------------------------------------------------------------
 
 (defn- extract-time-from-success-msg [s]
   (-> s

        child (spawn "lein cljsbuild once" (convert-cwd prj-key))
        inside-error? (atom false)
        err-msg-buffer (atom "")
        err-msg-timeout nil]
    (.setEncoding (.-stderr child) "utf8")
    (.setEncoding (.-stdout child) "utf8")
    (.on (.-stderr child) "data"
      #(on-console-output % c inside-error? err-msg-buffer err-msg-timeout))
    (.on (.-stdout child) "data"
      #(on-console-output % c inside-error? err-msg-buffer err-msg-timeout))
    (.on child "close" #(on-close-child c))
    ;; return the channel
    c))


(defn- extract-target-from-start-msg [s]
  (-> s
    (replace #"^Compiling \"" "")
    (replace #"\".+$" "")))