Is it possible to get the compiler to exit early, failing the build, if a compile time warning is raised?

前端 未结 3 1522
情深已故
情深已故 2021-01-17 18:13

I find the compile time warnings very useful, but I can occasionally miss them, especially if it\'s on a pull request where the tests are running on a CI server.

Ide

3条回答
  •  难免孤独
    2021-01-17 18:33

    In your mix.exs:

    def project do
      [...,
       aliases: aliases]
    end
    
    defp aliases do
      ["compile": ["compile --warnings-as-errors"]]
    end
    

    Then mix compile will pass --warnings-as-errors to the compile.elixir subtask.

    This also works for mix test since it runs the compile task implicitly.


    If you don't add an alias, you can still run mix compile --warnings-as-errors and it will do what you expect, but mix test --warnings-as-errors will not do what you expect, since the flag does not reach the compile.elixir task.

提交回复
热议问题