Skip to content

Commit

Permalink
Don't exit auto builds if reloading Clojure code fails.
Browse files Browse the repository at this point in the history
Closes #131.
  • Loading branch information
emezeske committed Oct 1, 2012
1 parent 09a39fa commit 9d33c7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions support/src/cljsbuild/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
(catch Throwable e
(notify-cljs
notify-command
(str "Compiling \"" output-file "\" failed:") red)
(str "Compiling \"" output-file "\" failed.") red)
(pst+ e))))))

(defn- get-mtimes [paths]
Expand Down Expand Up @@ -79,14 +79,20 @@
(subs path (count parent))
path)))

(defn reload-clojure [paths compiler-options]
(defn reload-clojure [paths compiler-options notify-command]
; Incremental builds will use cached JS output unless one of the cljs input files
; has been modified. Since reloading a clj file *might* affect the build, but does
; not affect any cljs file mtimes, we have to clear the cache here to force everything
; to be rebuilt.
(fs/delete-dir (:output-dir compiler-options))
(doseq [path paths]
(load (drop-extension path))))
(try
(load (drop-extension path))
(catch Throwable e
(notify-cljs
notify-command
(str "Reloading Clojure file \"" path "\" failed.") red)
(pst+ e)))))

(defn run-compiler [cljs-path crossover-path crossover-macro-paths
compiler-options notify-command incremental?
Expand All @@ -106,9 +112,9 @@
clj-modified (list-modified output-mtime clj-mtimes)
cljs-modified (list-modified output-mtime cljs-mtimes)]
(when (seq macro-modified)
(reload-clojure (map macro-classpath-files macro-modified) compiler-options))
(reload-clojure (map macro-classpath-files macro-modified) compiler-options notify-command))
(when (seq clj-modified)
(reload-clojure (map (partial relativize cljs-path) clj-files) compiler-options))
(reload-clojure (map (partial relativize cljs-path) clj-files) compiler-options notify-command))
(when (or (seq macro-modified) (seq clj-modified) (seq cljs-modified))
(compile-cljs cljs-path compiler-options notify-command incremental?))))
dependency-mtimes))
2 changes: 1 addition & 1 deletion support/test/cljsbuild/test/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
(fs/mod-time "crossovers/b.cljs") => mtime :times 1
(fs/mod-time crossover-macro-absolute) => mtime :times 1
(fs/mkdirs anything) => nil
(reload-clojure [crossover-macro-classpath] compiler-options) => nil :times 1
(reload-clojure [crossover-macro-classpath] compiler-options notify-command) => nil :times 1
(cljs/build cljs-path compiler-options) => nil :times 1))

0 comments on commit 9d33c7e

Please sign in to comment.