Reputation: 3651
I would like to run two elixir scripts, first.exs
and second.exs
.
I would like second to also run first. What would be a nice way to run this?
For example, the code could look something like this:
first.exs
IO.puts "first"
second.exs
IO.puts "second"
System.cmd("mix run first.exs")
And would output something like this:
mix run first.exs
first
mix run second
first
second
I would like to avoid using System.cmd
though and use the Mix
module if possible
Upvotes: 4
Views: 3545
Reputation: 222108
You can use Code.eval_file
:
Code.eval_file "first.exs"
$ cat first.exs
IO.puts "first"
$ cat second.exs
IO.puts "second"
Code.eval_file "first.exs"
$ mix run second.exs
second
first
Upvotes: 12