diff --git a/lib/igniter.ex b/lib/igniter.ex index bca1057..b1a8d06 100644 --- a/lib/igniter.ex +++ b/lib/igniter.ex @@ -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 @@ -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" @@ -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, " ")}") diff --git a/lib/util/install.ex b/lib/util/install.ex index 8f59018..d6ae4bf 100644 --- a/lib/util/install.ex +++ b/lib/util/install.ex @@ -97,9 +97,6 @@ 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() @@ -107,7 +104,10 @@ defmodule Igniter.Util.Install do |> 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")