Skip to content
Browse files

Add an :assert option that sets *assert* during compilation.

Closes #132.
  • Loading branch information...
1 parent 9d33c7e commit de616661549f29d93a37691e5687b89a19e67417 @emezeske committed
View
1 plugin/src/leiningen/cljsbuild.clj
@@ -91,6 +91,7 @@
(:compiler build#)
(:parsed-notify-command build#)
(:incremental build#)
+ (:assert build#)
mtimes#)))]
(when ~watch?
(Thread/sleep 100)
View
1 plugin/src/leiningen/cljsbuild/config.clj
@@ -29,6 +29,7 @@
:jar false
:notify-command nil
:incremental true
+ :assert true
:compiler default-compiler-options})
(defn convert-builds-map [options]
View
15 plugin/test/leiningen/test/cljsbuild.clj
@@ -58,7 +58,8 @@
(def build-id "build-id")
(def source-path "source-path")
-(def incremental false)
+(def incremental? false)
+(def assert? false)
(def compiler
{:output-to "output-to"
@@ -73,7 +74,8 @@
:source-path source-path
:jar true
:notify-command ["notify"]
- :incremental incremental
+ :incremental incremental?
+ :assert assert?
:compiler compiler}))
(def parsed-builds
@@ -139,7 +141,8 @@
crossover-macros
parsed-compiler
anything
- incremental
+ incremental?
+ assert?
{}) => nil :times 1)))
(fact "bad build IDs are detected"
@@ -171,7 +174,8 @@
crossover-macros
parsed-compiler
anything
- incremental
+ incremental?
+ assert?
{}) => nil :times 1))
(fact "compile-hook does not call through to the compiler when task fails"
@@ -217,7 +221,8 @@
crossover-macros
parsed-compiler
anything
- incremental
+ incremental?
+ assert?
{}) => nil :times 1
(cljsbuild.test/run-tests parsed-commands) => 0 :times 1)))
View
1 plugin/test/leiningen/test/cljsbuild/config.clj
@@ -37,6 +37,7 @@
:jar true
:notify-command ["g"]
:incremental false
+ :assert false
:compiler
{:output-to "h"
:output-dir "i"
View
4 sample.project.clj
@@ -77,6 +77,10 @@
; be built incrementally. This probably shouldn't be disabled except for troubleshooting.
; Defaults to true.
:incremental true
+ ; Determines whether assertions are enabled for the ClojureScript code. Technically, this
+ ; binds clojure.core/*assert*, which is respected by the ClojureScript compiler.
+ ; Defaults to true.
+ :assert true
; The :compiler options are passed directly to the ClojureScript compiler.
:compiler {
; The path to the JavaScript file that will be output.
View
9 support/src/cljsbuild/compiler.clj
@@ -33,7 +33,7 @@
(pst+ e))))
(println (colorizer message)))
-(defn- compile-cljs [cljs-path compiler-options notify-command incremental?]
+(defn- compile-cljs [cljs-path compiler-options notify-command incremental? assert?]
(let [output-file (:output-to compiler-options)
output-file-dir (fs/parent output-file)]
(println (str "Compiling \"" output-file "\" from \"" cljs-path "\"..."))
@@ -44,7 +44,8 @@
(fs/mkdirs output-file-dir))
(let [started-at (System/nanoTime)]
(try
- (build cljs-path compiler-options)
+ (binding [*assert* assert?]
+ (build cljs-path compiler-options))
(notify-cljs
notify-command
(str "Successfully compiled \"" output-file "\" in " (elapsed started-at) ".") green)
@@ -96,7 +97,7 @@
(defn run-compiler [cljs-path crossover-path crossover-macro-paths
compiler-options notify-command incremental?
- last-dependency-mtimes]
+ assert? last-dependency-mtimes]
(let [output-file (:output-to compiler-options)
output-mtime (if (fs/exists? output-file) (fs/mod-time output-file) 0)
macro-files (map :absolute crossover-macro-paths)
@@ -116,5 +117,5 @@
(when (seq clj-modified)
(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?))))
+ (compile-cljs cljs-path compiler-options notify-command incremental? assert?))))
dependency-mtimes))
View
2 support/test/cljsbuild/test/compiler.clj
@@ -21,6 +21,7 @@
:optimizations :advanced
:pretty-print false})
(def notify-command {:shell ["a" "b"] :test "c"})
+(def assert? false)
(def incremental? true)
(def mtime 1234)
@@ -32,6 +33,7 @@
compiler-options
notify-command
incremental?
+ assert?
{}) => (just {"src-cljs/a.cljs" mtime,
"crossovers/b.cljs" mtime,
crossover-macro-absolute mtime})

0 comments on commit de61666

Please sign in to comment.
Something went wrong with that request. Please try again.