0

So I was trying to run scripts one after another. But in between there has to be something else like ecto.create. But when I do mix work it didn't really work. Only the first script runs.

def aliases do
[
    work: [
        "run script1.exs",
        "ecto.create",
        "run script2.exs"
    ]
]
end

Does anyone know how to solve this?

Shih-Min Lee
  • 9,350
  • 7
  • 37
  • 67

1 Answers1

0

As I said before you can use rerun

 defp aliases do
    [
      other_task: &hello/1,
      work: &work/1
    ] 
 end

 defp work(_) do
   Mix.Task.run("run", ["script1.exs"])
   Mix.Task.run("ecto.create")
   Mix.Task.run("other_task")
   Mix.Task.rerun("run", ["script2.exs"])
 end

 defp hello(_) do
   Mix.shell.info "Hello world"
 end

 def aliases do
    [
        work: "run -r script1.exs -r script2.exs"
    ]
 end

Note - If you insist to rerun "run" then use Mix.Task.rerun/2

Mohammad Ahmad
  • 120
  • 2
  • 7