Skip to content

Commit

Permalink
fix: prevent crash on specific cases with igniter.new
Browse files Browse the repository at this point in the history
improvement: more consistent initial impl of `elixirc_paths`

chore: share deps_compile code with installer
  • Loading branch information
zachdaniel committed Jul 10, 2024
1 parent bfcee7f commit e79a384
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
6 changes: 1 addition & 5 deletions installer/lib/mix/tasks/igniter.new.ex
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ defmodule Mix.Tasks.Igniter.New do
|> File.read!()
|> Code.eval_string([], file: Path.expand("mix.exs"))

Mix.Task.reenable("deps.compile")
Mix.Task.run("deps.compile", ["--ignore-module-conflict"])

Mix.Task.reenable("compile")
Mix.Task.run("compile", ["--ignore-module-conflict"])
Igniter.Util.DepsCompile.run()

exit_code ->
Mix.shell().info("""
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion installer/mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Igniter.New.MixProject do
use Mix.Project

@version "0.2.3"
@version "0.2.4"
@scm_url "https://github.com/ash-project/igniter"

def project do
Expand Down
3 changes: 0 additions & 3 deletions lib/igniter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,6 @@ defmodule Igniter do

Igniter.Util.DepsCompile.run()

Mix.Task.reenable("compile")
Mix.Task.run("compile", ["--ignore-module-conflict"])

exit_code ->
Mix.shell().info("""
mix deps.get returned exited with code: `#{exit_code}`
Expand Down
2 changes: 1 addition & 1 deletion lib/igniter/project/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule Igniter.Project.Test do
zipper <-
Igniter.Code.Common.add_code(
zipper,
"defp elixirc_paths(:test), do: [\"lib\", \"test/support\"]"
"defp elixirc_paths(:test), do: elixirc_paths(:dev) ++ [\"test/support\"]"
) do
{:ok,
Igniter.Code.Common.add_code(
Expand Down
1 change: 1 addition & 0 deletions lib/mix/tasks/igniter.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ defmodule Mix.Tasks.Igniter.Install do
@impl true
@shortdoc "Install a package or packages, and run any associated installers."
def run(argv) do
Mix.Task.run("compile")
{packages, argv} = Enum.split_while(argv, fn arg -> !String.starts_with?(arg, "-") end)

if Enum.empty?(packages) do
Expand Down
11 changes: 10 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ defmodule Igniter.MixProject do
version: @version,
elixir: "~> 1.15",
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
description: @description,
aliases: aliases(),
package: package(),
Expand All @@ -21,6 +22,14 @@ defmodule Igniter.MixProject do
]
end

defp elixirc_paths(:test) do
elixirc_paths(:dev) ++ ["test/support"]
end

defp elixirc_paths(_env) do
["lib", "installer/lib/private"]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
Expand Down Expand Up @@ -63,7 +72,7 @@ defmodule Igniter.MixProject do
[
name: :igniter,
licenses: ["MIT"],
files: ~w(lib .formatter.exs mix.exs README* LICENSE*
files: ~w(lib installer/lib/private .formatter.exs mix.exs README* LICENSE*
CHANGELOG*),
links: %{
GitHub: "https://github.com/ash-project/igniter",
Expand Down

0 comments on commit e79a384

Please sign in to comment.