From f3c2eda984d6057b127fdd583ea3b5f73dde9b0b Mon Sep 17 00:00:00 2001 From: Craig P Jolicoeur Date: Fri, 17 Apr 2020 12:00:12 -0400 Subject: [PATCH] Don't run torch.gen tasks at top-level of umbrella 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. --- lib/mix/tasks/torch.gen.html.ex | 4 ++++ lib/mix/tasks/torch.install.ex | 4 ++++ lib/mix/tasks/torch.uninstall.ex | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib/mix/tasks/torch.gen.html.ex b/lib/mix/tasks/torch.gen.html.ex index 4c96263f..784c4d19 100644 --- a/lib/mix/tasks/torch.gen.html.ex +++ b/lib/mix/tasks/torch.gen.html.ex @@ -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 diff --git a/lib/mix/tasks/torch.install.ex b/lib/mix/tasks/torch.install.ex index 80999c53..5dbee35c 100644 --- a/lib/mix/tasks/torch.install.ex +++ b/lib/mix/tasks/torch.install.ex @@ -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}", [ diff --git a/lib/mix/tasks/torch.uninstall.ex b/lib/mix/tasks/torch.uninstall.ex index dd7eec4b..cee701d1 100644 --- a/lib/mix/tasks/torch.uninstall.ex +++ b/lib/mix/tasks/torch.uninstall.ex @@ -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 = [