@@ -238,14 +238,10 @@ defmodule Mix do
238238
239239 In the example above, we have defined three aliases. One is `mix c`
240240 which is a shortcut for `mix compile`. Another is named
241- `mix hello`, which is the equivalent to the `Mix.Tasks.Hello`
242- we have defined in the [Mix.Task section](#module-mix-task).
243-
244- The third is named `mix paid_task`, which runs the task `paid.task` with
245- several arguments, including one pulled from an environment variable.
246- Defining this as a function means that the environment variable is only
247- evaluated when this specific task is run, not when `mix.exs` is loaded
248- before each `mix` command.
241+ `mix hello` and the third is named `mix paid_task`, which executes
242+ the code inside a custom function to invoke the `paid.task` task
243+ with several arguments, including one pulled from an environment
244+ variable.
249245
250246 Aliases may also be lists, specifying multiple tasks to be run
251247 consecutively:
@@ -265,19 +261,13 @@ defmodule Mix do
265261 Where `&clean_extra/1` would be a function in your `mix.exs`
266262 with extra cleanup logic.
267263
268- Arguments given to the alias will be appended to the arguments of
269- the last task in the list. Except when overriding an existing task.
270- In this case, the arguments will be given to the original task,
271- in order to preserve semantics. For example, in the `:clean` alias
272- above, the arguments given to the alias will be passed to "clean"
273- and not to `clean_extra/1`.
274-
275- Aliases defined in the current project do not affect its dependencies
276- and aliases defined in dependencies are not accessible from the
277- current project.
264+ If the alias is overriding an existing task, the arguments given
265+ to the alias will be forwarded to the original task in order to
266+ preserve semantics. Otherwise arguments given to the alias are
267+ appended to the arguments of the last task in the list.
278268
279- Aliases can be used very powerfully to also run Elixir scripts and
280- shell commands, for example:
269+ Another use case of aliases is to run Elixir scripts and shell
270+ commands, for example:
281271
282272 # priv/hello1.exs
283273 IO.puts("Hello One")
@@ -301,10 +291,15 @@ defmodule Mix do
301291 then `mix cmd` to execute a command line shell script. This shows how
302292 powerful aliases mixed with Mix tasks can be.
303293
304- Mix tasks are designed to run only once. This prevents the same task
305- from being executed multiple times. For example, if there are several tasks
306- depending on `mix compile`, the code will be compiled once. Tasks can
307- be executed again if they are explicitly reenabled using `Mix.Task.reenable/1`:
294+ One commit pitfall of aliases comes when trying to invoke the same task
295+ multiple times. Mix tasks are designed to run only once. This prevents
296+ the same task from being executed multiple times. For example, if there
297+ are several tasks depending on `mix compile`, the code will be compiled
298+ only once.
299+
300+ Similary, `mix format` can only be invoked once. So if you have an alias
301+ that attempts to invoke `mix format` multiple times, it won't work unless
302+ it is explicitly reenabled using `Mix.Task.reenable/1`:
308303
309304 another_alias: [
310305 "format --check-formatted priv/hello1.exs",
@@ -314,15 +309,14 @@ defmodule Mix do
314309 ]
315310
316311 Some tasks are automatically reenabled though, as they are expected to
317- be invoked multiple times. They are: `mix cmd`, `mix do`, `mix loadconfig`,
318- `mix profile.cprof`, `mix profile.eprof`, `mix profile.fprof`, `mix run`,
319- and `mix xref`.
320-
321- It is worth mentioning that some tasks, such as in the case of the
322- `mix format` command in the example above, can accept multiple files so it
323- could be rewritten as:
324-
325- another_alias: ["format --check-formatted priv/hello1.exs priv/hello2.exs"]
312+ be invoked multiple times, such as: `mix cmd`, `mix do`, `mix xref`, etc.
313+
314+ Finally, aliases defined in the current project do not affect its
315+ dependencies and aliases defined in dependencies are not accessible
316+ from the current project, with the exception of umbrella projects.
317+ Umbrella projects will run the aliases of its children when the
318+ umbrella project itself does not define said alias and there is no
319+ task with said name.
326320
327321 ## Environment variables
328322
0 commit comments