【问题标题】:How to run many mix phx.gen.html commands in one .exs script如何在一个 .exs 脚本中运行多个混合 phx.gen.html 命令
【发布时间】:2019-03-18 06:37:41
【问题描述】:

我正在尝试从脚本中朗读许多混合 phx.gen.html 命令,但只执行第一个命令。我尝试了不同的方法,其中一些如下,但没有任何效果:

Mix.Task.run "phx.gen.html", Parser.parse "Contacts Skype skypes user_id:references:users skype --parent user"
Mix.Task.run "phx.gen.html", Parser.parse "Contacts Phone phones user_id:references:users number --parent user"
Mix.Task.run "phx.gen.html", Parser.parse "Contacts Address addresses user_id:references:users country state region city zip street house corp flat  --parent user"

============

commands = [
  "Contacts Skype skypes user_id:references:users skype --parent user",
"Contacts Phone phones user_id:references:users number --parent user",
"Contacts Address addresses user_id:references:users country state region city zip street house corp flat  --parent user"]


for command <- commands do
  list = String.split(command, " ")
  list = ["phx.gen.html" | list]
  System.cmd("mix", list)
end


for command <- commands do
  list = String.split(command, " ")
  IO.inspect list
  Mix.Task.run "phx.gen.html", list
end

【问题讨论】:

    标签: elixir phoenix-framework elixir-mix


    【解决方案1】:

    您可能必须在调用该任务后reenable。

    for command <- commands do
      list = String.split(command, " ")
      list = ["phx.gen.html" | list]
      System.cmd("mix", list)
      Mix.Task.reenable "phx.gen.html"
    end
    

    【讨论】:

    • 它没有帮助,执行第一个命令并挂起控制台,直到我按 ctrl+C
    • 实际上它起作用了,我错误地将 reenable 输入为 reanable
    • 一切正常,除了迁移文件的编号顺序错误,而不是它们在命令列表中的顺序。其中一些具有相同的编号,这意味着它们是在同一秒内创建的。导致以后无法申请,我需要手动修改他们的号码才能申请,你知道怎么解决吗?
    • 我已经通过在重新启用任务之前设置超时 :timer.sleep(1000) 来解决它,现在迁移具有唯一编号
    猜你喜欢
    • 2017-08-16
    • 2020-05-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 1970-01-01
    • 2023-01-12
    • 2011-07-14
    • 2014-01-25
    相关资源
    最近更新 更多