Skip to content

Commit

Permalink
Fixed a bug where the Lein-Tornado process terminated on reader's err…
Browse files Browse the repository at this point in the history
…or because of `(require ... :reload)` not being in the `try` form.
  • Loading branch information
JanSuran03 committed Dec 17, 2021
1 parent 5850bf7 commit d5a32bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## 0.2.1
Fixed a bug where the Lein-Tornado process terminated on reader's error because of `(require ... :reload)` not being in the `try` form.

## 0.2.0
Updated the version of Tornado dependency from 0.2.4 to 0.2.5.

Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject org.clojars.jansuran03/lein-tornado "0.2.0"
(defproject org.clojars.jansuran03/lein-tornado "0.2.1"
:description "A Clojure plugin for automatic compilation of Tornado stylesheets."
:url "https://github.com/JanSuran03/lein-tornado"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down
33 changes: 18 additions & 15 deletions src/leiningen/tornado.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[leiningen.core.eval :refer [eval-in-project]]
[leiningen.help :as help]))

(defn error
(defn- error
"Pretty prints an exception (no 40 lines of unreadable stacktrace) -
prints out the error message and calmly aborts the process."
[& args]
Expand Down Expand Up @@ -66,20 +66,23 @@
`(let [modified-namespaces# (ns-tracker/ns-tracker ~tornado-source-paths)]
(loop [modified-nss# ~all-stylesheet-namespaces]
(when (seq modified-nss#)
(println "Reloading modified namespaces...")
(doseq [ns# modified-nss#]
(require (symbol ns#) :reload))
(println "Namespaces reloaded.")
(try (doseq [build# ~builds]
(let [{stylesheet# :stylesheet
id# :id
flags# :compiler} build#]
(println " Compiling build" (name id#) "...")
(compiler/css flags# stylesheet#)
(println " Successful.")))
(println "All builds were successfully recompiled.")
(catch Exception e#
(println "Error: " (.getMessage e#)))))
(try
(println "Reloading modified namespaces...")
(println "--")
(doseq [ns# modified-nss#]
(println "reloading: " ns#)
(require (symbol ns#) :reload))
(println "Namespaces reloaded.")
(doseq [build# ~builds]
(let [{stylesheet# :stylesheet
id# :id
flags# :compiler} build#]
(println " Compiling build" (name id#) "...")
(compiler/css flags# stylesheet#)
(println " Successful.")))
(println "All builds were successfully recompiled.")
(catch Exception e#
(println "Error: " (.getMessage e#)))))
(when ~watch? nil
(Thread/sleep 500)
;; A funciton to return a set of modified namespaces is called, called every 500 millieconds.
Expand Down

0 comments on commit d5a32bd

Please sign in to comment.