Search code examples
elixirelixir-mix

How do I run a mix task from within a mix task?


I would like to run a mix task from within a custom mix task.

Something like

def run(_) do
  Mix.Shell.cmd("mix edeliver build release")
  #do other stuff

But I cannot figure out how to execute a shell command. If there is any easier way (besides just making a bash script), let me know.


Solution

  • Shell is the redundant link here. If you want to run edeliver task, run Mix.Tasks.Edeliver#run:

    def run(_) do
      Mix.Tasks.Edeliver.run(~w|build release|)
      # do other stuff