Skip to content

Commit

Permalink
fix: don't show unnecessary diff output
Browse files Browse the repository at this point in the history
fix: don't compile before fetching deps
  • Loading branch information
zachdaniel committed Jun 21, 2024
1 parent faff459 commit 0e82c3a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
28 changes: 19 additions & 9 deletions lib/igniter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,23 @@ defmodule Igniter do
"#{String.pad_trailing(to_string(line_number), space_padding)} #{IO.ANSI.yellow()}| #{IO.ANSI.green()}#{line}#{IO.ANSI.reset()}"
end)

Mix.shell().info("""
Create: #{Rewrite.Source.get(source, :path)}
if String.trim(diffish_looking_text) != "" do
Mix.shell().info("""
Create: #{Rewrite.Source.get(source, :path)}
#{diffish_looking_text}
""")
#{diffish_looking_text}
""")
end
else
Mix.shell().info("""
Update: #{Rewrite.Source.get(source, :path)}
diff = Rewrite.Source.diff(source) |> IO.iodata_to_binary()

#{Rewrite.Source.diff(source)}
""")
if String.trim(diff) != "" do
Mix.shell().info("""
Update: #{Rewrite.Source.get(source, :path)}
#{diff}
""")
end
end
end)
end
Expand All @@ -392,7 +398,7 @@ defmodule Igniter do
|> Mix.shell().info()
end

if igniter.tasks != [] do
if igniter.tasks != [] && "--yes" not in argv do
message =
if result_of_dry_run == :dry_run_with_no_changes do
"The following tasks will be run"
Expand Down Expand Up @@ -421,6 +427,10 @@ defmodule Igniter do
|> Rewrite.write_all()
|> case do
{:ok, _result} ->
unless Enum.empty?(igniter.tasks) do
Mix.shell().cmd("mix deps.get")
end

igniter.tasks
|> Enum.each(fn {task, args} ->
Mix.shell().cmd("mix #{task} #{Enum.join(args, " ")}")
Expand Down
8 changes: 4 additions & 4 deletions lib/util/install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ defmodule Igniter.Util.Install do

case Mix.shell().cmd("mix deps.get") do
0 ->
Mix.Task.reenable("compile")
Mix.Task.run("compile")

Mix.Project.clear_deps_cache()
Mix.Project.pop()

"mix.exs"
|> File.read!()
|> Code.eval_string([], file: Path.expand("mix.exs"))

Mix.Task.run("deps.compile", Enum.map(install_list, &to_string/1))
Mix.Dep.clear_cached()
Mix.Project.clear_deps_cache()

Mix.Task.run("deps.compile")

Mix.Task.reenable("compile")
Mix.Task.run("compile")
Expand Down

0 comments on commit 0e82c3a

Please sign in to comment.