mash/lib/mash/execution.ex
2023-08-10 08:30:20 +00:00

16 lines
332 B
Elixir

defmodule Mash.Execution do
@moduledoc """
Wraps execution of a job run function in a Task and a StringIO for tracking output.
"""
def run(%{run: run} = job) do
{:ok, io_pid} = StringIO.open("")
task =
Task.async(fn ->
{%{job | io_pid: io_pid}, run.(io_pid)}
end)
{task, io_pid}
end
end