While I never tried to run the mix task using Mix.shell.cmd from inside another mix task, and I'm not sure if this is the best practice, it seems like something like what you are aiming for will work:
def run(args) do Mix.Shell.cmd("mix test", fn(output) -> IO.write(output) end) # (...) end
The above code runs the tests through mix test and prints their output. Note: the above code is based on Mix 1.3.4, the interface is slightly different in 1.4.0.
Which may be a more elegant approach, although it will create a mixing alias for a โcomplexโ task consisting of tasks for which you depend and your user:
# inside mix.exs def project do [ # (...) aliases: [ "composite.task": [ "test", "edeliver build release", "my.custom.task", ] ] ] end
Now running mix composite.task should do two other tasks before my.custom.task .
source share