Fl4m3Ph03n1x

Fl4m3Ph03n1x

Create an alias for another task in mix.exs?

Background

So I am using this library mix-test.watch from @lpil which I really like.

Usually I just run mix test.watch and I let the process running.

As a bonus to this library, you can also execute it by passing the --only flag. For example, if I want to watch only my “super_duper_tests” I can do it like this: mix text.watch --only super_duper_tests and this will only watch all the tests that have, for example, the @moduletag :super_duper_tests on them.

Enter Alias

So, this is all fun, but I am lazy and I don’t like typing. So I want to create an alias like this:

mix test.watch.super_duper that will be translated to mix text.watch --only super_duper_tests.

To achieve this I tried the following on my mix.exs file:

defp aliases do
  [
    "test.watch.super_duper": ["test.watch --only super_duper_tests"]
  ]
end

Problem

You may have guessed, since I am posting here, that this is not working. When I try my new alias, I get the error message Could not find test.watch task.

So obviously I am doing something wrong in the configuration.

Questions

How can I create an alias for mix test.watch?

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

This is how I defined it:

[{:mix_test_watch, "~> 1.0", only: :dev}]

Perhaps it should be:

[{:mix_test_watch, "~> 1.0", only: [:dev, :test]}]

right?

EDIT

Yep, it needed to be [{:mix_test_watch, "~> 1.0", only: [:dev, :test]}].

Also Liked

hauleth

hauleth

BTW I prefer to use entr or watchman with mix test --listen-on-stdin

stefanchrobot

stefanchrobot

I personally use watchexec:

watchexec -e 'ex,exs,eex,leex' -- 'mix format && mix test --stale'
LostKobrakai

LostKobrakai

Last Post!

stuartbain

stuartbain

Blog post showing usage of entr
https://jvns.ca/blog/2020/06/28/entr/

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement