Skip to content

Commit

Permalink
Don't run torch.gen tasks at top-level of umbrella
Browse files Browse the repository at this point in the history
When in an umbrella app, raise an error if any of the
torch.gen.* Mix tasks are run at the top-level instead of
in the app-specific level directories.
  • Loading branch information
cpjolicoeur committed Apr 17, 2020
1 parent 649de7e commit f3c2eda
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/mix/tasks/torch.gen.html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ defmodule Mix.Tasks.Torch.Gen.Html do
@commands ~w[phx.gen.html phx.gen.context]

def run(args) do
if Mix.Project.umbrella?() do
Mix.raise("mix torch.gen.html can only be run inside an application directory")
end

%{format: format} = Mix.Torch.parse_config!("torch.gen.html", args)

# First, backup the projects existing templates if they exist
Expand Down
4 changes: 4 additions & 0 deletions lib/mix/tasks/torch.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ defmodule Mix.Tasks.Torch.Install do
"""

def run(args) do
if Mix.Project.umbrella?() do
Mix.raise("mix torch.install can only be run inside an application directory")
end

%{format: format, otp_app: otp_app} = Mix.Torch.parse_config!("torch.install", args)

Mix.Torch.copy_from("priv/templates/#{format}", [
Expand Down
4 changes: 4 additions & 0 deletions lib/mix/tasks/torch.uninstall.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ defmodule Mix.Tasks.Torch.Uninstall do
"""

def run(args) do
if Mix.Project.umbrella?() do
Mix.raise("mix torch.uninstall can only be run inside an application directory")
end

%{format: format, otp_app: otp_app} = Mix.Torch.parse_config!("torch.uninstall", args)

paths = [
Expand Down

0 comments on commit f3c2eda

Please sign in to comment.