I have a project which used to be run with mix run
and I sometimes use mix run
options like --no-deps-check
or --no-compile
. I try to convert the project to a custom mix task. Basically, it works ( mix my-project
runs fine) but it seems it makes me lose the mix run
options. They are options of mix run
, not just mix. How to give them to mix when running my custom task?
Does your task call mix run
internally?
No (I don’t even know how I could do it).
Than I can assure you that your task is not compiling the project and it is not checking the deps
mix disagrees and displays “Compiling 1 file (.ex)”
Please post your mix task, or it will be impossible to tell what’s happening. Also can you clarify why you need support for mix run
flags, if you don’t use mix run
?
defmodule Mix.Tasks.Drink do
import Drink.Config
use Mix.Task
# shortdoc seems ignored?
@shortdoc "Starts the Drink authoritative DNS server"
def run(args) do
Drink.Toml.load_configs
|> Drink.Cli.run(args)
|> Drink.Config.start_link
if config()["services"]["report"] do
Drink.Reports.start_link
end
if config()["ipc-socket"] do
Drink.Ipc.start_link(config()["ipc-socket"])
end
Drink.Server.start()
end
end
The reason I wanted to use these options is that the program can be run by a different user and I want to control if there is compliation at startup or not (something I can do with mix run
).
This is a task from dependency, right? Or is it a part of a project which it is called upon (i.e. defined in lib/
dir)?