Skip to content

Commit

Permalink
Remove double put_source_path pall
Browse files Browse the repository at this point in the history
  • Loading branch information
luk-pau-es committed Oct 31, 2022
1 parent 450600a commit 135eab9
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 51 deletions.
30 changes: 12 additions & 18 deletions examples/simple_umbrella_app/apps/app_a/mix.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule AppA.MixProject do
use Mix.Project

def project do
[
app: :app_a,
Expand All @@ -11,23 +10,18 @@ defmodule AppA.MixProject do
lockfile: "../../mix.lock",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
# {:sibling_app_in_umbrella, in_umbrella: true}
deps: deps(),

gradient: [

enabled: true,


]

]
end

defp deps, do: []

end
28 changes: 10 additions & 18 deletions examples/simple_umbrella_app/apps/app_b/mix.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule AppB.MixProject do
use Mix.Project

def project do
[
app: :app_b,
Expand All @@ -11,23 +10,16 @@ defmodule AppB.MixProject do
lockfile: "../../mix.lock",
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[{:app_a, in_umbrella: true}
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
# {:sibling_app_in_umbrella, in_umbrella: true}
deps: deps(),

gradient: [


]

]
end

defp deps, do: [{:app_a, in_umbrella: true}]

end
19 changes: 10 additions & 9 deletions examples/simple_umbrella_app/mix.exs
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
defmodule SimpleUmbrellaApp.MixProject do
use Mix.Project

def project do
[
apps_path: "apps",
version: "0.1.0",
start_permanent: Mix.env() == :prod,
deps: deps()
deps: deps(),

gradient: [

enabled: false,


]

]
end

# Dependencies listed here are available only for this
# project and cannot be accessed from applications inside
# the apps folder.
#
# Run "mix help deps" for examples and options.
defp deps do
[{:gradient, path: "../../"}]
[{:gradient, path: "../../", override: true}]
end
end
13 changes: 11 additions & 2 deletions lib/gradient.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ defmodule Gradient do
with {:ok, asts} <- ElixirFileUtils.get_forms(path, module),
{:ok, first_ast} <- get_first_forms(asts),
{:elixir, _} <- wrap_language_name(first_ast) do
# IO.inspect(asts, label: :ASTS)

asts
|> Enum.map(fn ast ->
ast =
Expand Down Expand Up @@ -87,6 +89,8 @@ defmodule Gradient do
end

defp maybe_use_tokens(forms, opts) do
# IO.inspect(forms, label: :FORMS)

unless opts[:no_tokens] do
Gradient.ElixirFileUtils.load_tokens(forms)
else
Expand Down Expand Up @@ -133,7 +137,7 @@ defmodule Gradient do
defp maybe_specify_forms(forms, opts) do
unless opts[:no_specify] do
forms
|> put_source_path(opts)
# |> put_source_path(opts)
|> AstSpecifier.specify()
else
forms
Expand All @@ -149,6 +153,8 @@ defmodule Gradient do
end

defp put_source_path(forms, opts) do
IO.inspect(opts, label: :OPTS)

case opts[:source_path] do
nil ->
case opts[:app_path] do
Expand All @@ -158,8 +164,11 @@ defmodule Gradient do
app_path ->
{:attribute, anno, :file, {path, line}} = hd(forms)

new_path =
(String.to_charlist(app_path) ++ '/' ++ path) |> IO.inspect(label: :NEW_PATH)

[
{:attribute, anno, :file, {String.to_charlist(app_path) ++ '/' ++ path, line}}
{:attribute, anno, :file, {new_path, line}}
| tl(forms)
]
end
Expand Down
4 changes: 1 addition & 3 deletions lib/mix/tasks/gradient.ex
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,7 @@ defmodule Mix.Tasks.Gradient do
end

defp ex_filename_from_beam(beam_path) do
ElixirFileUtils.get_forms(beam_path)
|> IO.inspect(label: :FORMS)
|> case do
case ElixirFileUtils.get_forms(beam_path) do
{:ok, code_forms} ->
# Convert the *.beam compiled filename to its corresponding *.ex source file
# (it's a charlist initially so we pipe it through to_string)
Expand Down
2 changes: 1 addition & 1 deletion test/mix/tasks/gradient_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ defmodule Mix.Tasks.GradientTest do
"_build/test/lib/app_b/ebin/Elixir.AppB.beam",
"_build/test/lib/app_b/ebin/Elixir.AppBHelper.beam"
]
} == run_task_and_return_files() |> IO.inspect()
} == run_task_and_return_files()
end

@tag umbrella: %{enabled: false}, app_a: %{no_config: true}, app_b: %{no_config: true}
Expand Down

0 comments on commit 135eab9

Please sign in to comment.