cat-bookmarker/deps/swoosh/lib/mix/tasks/swoosh.mailbox.server.ex

34 lines
796 B
Elixir
Raw Normal View History

2024-03-10 18:52:04 +00:00
defmodule Mix.Tasks.Swoosh.Mailbox.Server do
@moduledoc """
Starts the mailbox preview server.
## Command line options
This task accepts the same command-line arguments as `run`.
For additional information, refer to the documentation for `Mix.Tasks.Run`.
For example, to run `swoosh.mailbox.server` without checking dependencies:
mix swoosh.mailbox.server --no-deps-check
The `--no-halt` flag is automatically added.
"""
use Mix.Task
@shortdoc "Starts the mailbox preview server"
def run(args) do
Application.put_env(:swoosh, :serve_mailbox, true)
Mix.Task.run("run", run_args() ++ args)
end
defp run_args do
if iex_running?(), do: [], else: ["--no-halt"]
end
defp iex_running? do
Code.ensure_loaded?(IEx) && IEx.started?()
end
end