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

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
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
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement