fix: Properly inject MIX_ENV to subtasks
This commit is contained in:
parent
03e200a3b1
commit
7832ac109e
4 changed files with 17 additions and 8 deletions
|
@ -12,7 +12,7 @@ defmodule MashConfig do
|
|||
%{
|
||||
name: :compile_dev,
|
||||
needs: [:restore_cache],
|
||||
run: mix("compile", [], env: [{"MIX_ENV", "dev"}])
|
||||
run: mix("do", ["deps.compile,", "compile"], env: [{"MIX_ENV", "dev"}])
|
||||
},
|
||||
%{
|
||||
name: :test,
|
||||
|
@ -26,7 +26,7 @@ defmodule MashConfig do
|
|||
},
|
||||
%{
|
||||
name: :save_cache,
|
||||
needs: [:test, :compile_dev],
|
||||
needs: [:restore_cache],
|
||||
run: save_cache()
|
||||
},
|
||||
%{
|
||||
|
|
|
@ -13,7 +13,7 @@ Add mash to your dependencies like so:
|
|||
```elixir
|
||||
def deps do
|
||||
[
|
||||
{:mash, "~> 0.1.1"}
|
||||
{:mash, "~> 0.1.2"}
|
||||
]
|
||||
end
|
||||
```
|
||||
|
|
|
@ -15,10 +15,19 @@ defmodule Mash.Helpers do
|
|||
|
||||
mix_env =
|
||||
Enum.find_value(env, fn {key, value} -> key == "MIX_ENV" && value end) ||
|
||||
Atom.to_string(Mix.Task.preferred_cli_env(task_name)) ||
|
||||
Atom.to_string(Mix.env()) ||
|
||||
Mix.Task.preferred_cli_env(task_name) ||
|
||||
Mix.env() ||
|
||||
:dev
|
||||
|
||||
mix_env =
|
||||
case mix_env do
|
||||
env when is_binary(env) ->
|
||||
env
|
||||
|
||||
env ->
|
||||
Atom.to_string(env)
|
||||
end
|
||||
|
||||
fn io_pid ->
|
||||
cmd("mix", [task_name | args], io_pid, [{"MIX_ENV", mix_env} | env])
|
||||
end
|
||||
|
@ -74,9 +83,9 @@ defmodule Mash.Helpers do
|
|||
end
|
||||
|
||||
defp cmd(command, args, io_pid, env) do
|
||||
exec_string = "-c #{command} #{Enum.join(args, " ")}"
|
||||
exec_string = ~s(-c #{command} #{Enum.join(args, " ")})
|
||||
|
||||
System.cmd("script", ["-eqf", exec_string, "/dev/null"],
|
||||
System.cmd("script", ["/dev/null", "-eqf", exec_string],
|
||||
into: IO.stream(io_pid, :line),
|
||||
env: env,
|
||||
parallelism: true,
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -4,7 +4,7 @@ defmodule Mash.MixProject do
|
|||
def project do
|
||||
[
|
||||
app: :mash,
|
||||
version: "0.1.1",
|
||||
version: "0.1.2",
|
||||
elixir: "~> 1.14",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
|
|
Loading…
Reference in a new issue