Skip to content

Commit c4fa5c1

Browse files
committed
add a new cli flag to promote warnings to errors
1 parent 2513e1e commit c4fa5c1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/main/clojure/cljs/cli.clj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ classpath. Classpath-relative paths have prefix of @ or @/")
181181
[cfg level]
182182
(assoc-in cfg [:options :optimizations] (keyword level)))
183183

184+
(defn- promote-warn-opt
185+
[cfg warn-type-str]
186+
(let [warn-type (keyword warn-type-str)]
187+
(cond
188+
(= :all warn-type)
189+
(assoc-in cfg [:options :warnings] :error)
190+
191+
(contains? ana/*cljs-warnings* warn-type)
192+
(assoc-in cfg [:options :warnings warn-type] :error)
193+
194+
:else
195+
(throw
196+
(ex-info (str "Unknown warning type: " warn-type)
197+
{:cfg cfg :warn-type warn-type})))))
198+
184199
(defn- output-to-opt
185200
[cfg path]
186201
(assoc-in cfg [:options :output-to] path))
@@ -682,6 +697,13 @@ generic - the combinations must be explicitly supported"}
682697
(str "Set optimization level, only effective with "
683698
"--compile main option. Valid values are: none, "
684699
"whitespace, simple, advanced")}
700+
["-Werror"] {:group ::compile
701+
:fn promote-warn-opt
702+
:arg "warning-type"
703+
:doc (str "Promote a warning type to error. If |\"all|\" or no argument supplied "
704+
"serious warnings are promoted to errors.")
705+
:optional-arg? true
706+
:default "all"}
685707
["-t" "--target"] {:group ::main&compile :fn target-opt
686708
:arg "name"
687709
:doc

0 commit comments

Comments
 (0)