Moxley Stratton
Moxley Stratton

Reputation: 1039

How to run multiple mix tasks in one command

I have multiple mix tasks to run in succession. With other build tools, it is possible to run the tasks with a single statement, which saves any startup overhead after the first task. How can this be done with Elixir's mix command?

Upvotes: 21

Views: 3471

Answers (2)

Moxley Stratton
Moxley Stratton

Reputation: 1039

Comma-separate the list of tasks, and add them to mix do: mix do task1, task2, task3:

mix do deps.get, run hello.exs, ecto.migrate

For example, the above runs the tasks deps.get, run hello.exs, and ecto.migrate within one invocation of mix.

Upvotes: 29

Dinesh Balasubramanian
Dinesh Balasubramanian

Reputation: 21768

You can put an aliases in mix.exs and use it.

Eg: "ecto.setup": ["ecto.create", "ecto.migrate", "ecto.seed"] in this case mix ecto.setup will run create, migrate and seed in order

Upvotes: 9

Related Questions