Skip to content

Commit f29889d

Browse files
author
José Valim
committed
Make environment explicit on escript build
1 parent aee33ea commit f29889d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/mix/lib/mix/tasks/escript.build.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ defmodule Mix.Tasks.Escript.Build do
9191
app = Keyword.get(escript_opts, :app, project[:app])
9292
files = project_files()
9393

94-
escript_mod = String.to_atom(Atom.to_string(app) <> "-escript-main")
94+
escript_mod = String.to_atom(Atom.to_string(app) <> "_escript")
9595

9696
cond do
9797
!script_name ->
@@ -120,7 +120,7 @@ defmodule Mix.Tasks.Escript.Build do
120120
Mix.raise "Error creating escript: #{error}"
121121
end
122122

123-
Mix.shell.info "Generated escript #{filename}"
123+
Mix.shell.info "Generated escript #{filename} with MIX_ENV=#{Mix.env}"
124124
:ok
125125
true ->
126126
:noop
@@ -197,12 +197,12 @@ defmodule Mix.Tasks.Escript.Build do
197197
@app app
198198

199199
def main(args) do
200-
case :application.ensure_all_started(:elixir) do
200+
case Application.ensure_all_started(:elixir) do
201201
{:ok, _} ->
202202
start_app(@app)
203203
args = Enum.map(args, &List.to_string(&1))
204204
Kernel.CLI.run fn _ -> @module.main(args) end, true
205-
_ ->
205+
_ ->
206206
io_error "Elixir is not available, aborting."
207207
System.halt(1)
208208
end
@@ -213,7 +213,7 @@ defmodule Mix.Tasks.Escript.Build do
213213
end
214214

215215
defp start_app(app) do
216-
case :application.ensure_all_started(app) do
216+
case Application.ensure_all_started(app) do
217217
{:ok, _} -> :ok
218218
{:error, {app, reason}} ->
219219
io_error "Could not start application #{app}: " <>
@@ -223,7 +223,7 @@ defmodule Mix.Tasks.Escript.Build do
223223
end
224224

225225
defp io_error(message) do
226-
IO.puts :stderr, IO.ANSI.format([:red, :bright, message])
226+
IO.puts :stderr, IO.ANSI.format([:red, :bright, message])
227227
end
228228
end
229229

lib/mix/test/mix/tasks/escript_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ defmodule Mix.Tasks.EscriptTest do
4747

4848
in_fixture "escripttest", fn ->
4949
Mix.Tasks.Escript.Build.run []
50-
assert_received {:mix_shell, :info, ["Generated escript escriptest"]}
50+
assert_received {:mix_shell, :info, ["Generated escript escriptest with MIX_ENV=dev"]}
5151
assert System.cmd("escript", ["escriptest"]) == {"TEST\n", 0}
5252

5353
Mix.Tasks.Escript.Build.run []
54-
refute_received {:mix_shell, :info, ["Generated escript escriptest"]}
54+
refute_received {:mix_shell, :info, ["Generated escript escriptest with MIX_ENV=dev"]}
5555
end
5656
end
5757

@@ -60,7 +60,7 @@ defmodule Mix.Tasks.EscriptTest do
6060

6161
in_fixture "escripttest", fn ->
6262
Mix.Tasks.Escript.Build.run []
63-
assert_received {:mix_shell, :info, ["Generated escript ebin/escripttestwithpath"]}
63+
assert_received {:mix_shell, :info, ["Generated escript ebin/escripttestwithpath with MIX_ENV=dev"]}
6464
assert System.cmd("escript", ["ebin/escripttestwithpath"]) == {"TEST\n", 0}
6565
end
6666
end
@@ -70,7 +70,7 @@ defmodule Mix.Tasks.EscriptTest do
7070

7171
in_fixture "escripttest", fn ->
7272
Mix.Tasks.Escript.Build.run []
73-
assert_received {:mix_shell, :info, ["Generated escript ebin/escripttestwithdeps"]}
73+
assert_received {:mix_shell, :info, ["Generated escript ebin/escripttestwithdeps with MIX_ENV=dev"]}
7474
assert System.cmd("escript", ["ebin/escripttestwithdeps"]) == {"TEST\n", 0}
7575
end
7676
after

0 commit comments

Comments
 (0)