简体   繁体   中英

Elixir mix test set color to default to enabled

In my project I can run the command mix test --color which adds some colored output to the terminal. I would like to set this globally, so I can just run mix test and it automatically picks up that I want the output colored.

What I've tried...

  1. I've searched the online elixir docs about global configuration and global mix configuration.
  2. I've tried mix help too and couldn't see anything about global configuration.
  3. I've tried mix help test as well, it doesn't seem clear to me here how to add the option to the mix.exs file, or if it's possible to set global options somewhere.

I feel like this is probably possible, but after not coming up with anything I thought I'd ask here.

I am not aware of the system-wide, global setting. It might be easily done, though, on a per-project basis with :aliases option given to what MyApp.MixProject.project/0 callback in your mix.exs file returns.

defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      ...
      aliases: [test: "test --color"], # this
      ...
    ]
  end
  ...

Aliases are designed to provide exactly this functionality: mix test would now call mix test --color under the hood.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM