Skip to content

Commit 12a9d55

Browse files
eksperimentaljosevalim
authored andcommitted
Specify that "mix new" APP name only takes lowercase ASCII letters (#7872)
1 parent d10514c commit 12a9d55

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

lib/mix/lib/mix/tasks/new.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ defmodule Mix.Tasks.New do
168168
defp check_application_name!(name, inferred?) do
169169
unless name =~ Regex.recompile!(~r/^[a-z][a-z0-9_]*$/) do
170170
Mix.raise(
171-
"Application name must start with a letter and have only lowercase " <>
172-
"letters, numbers and underscore, got: #{inspect(name)}" <>
171+
"Application name must start with a lowercase ASCII letter, followed by " <>
172+
"lowercase ASCII letters, numbers, or underscores, got: #{inspect(name)}" <>
173173
if inferred? do
174174
". The application name is inferred from the path, if you'd like to " <>
175175
"explicitly name the application then use the \"--app APP\" option"

lib/mix/test/mix/tasks/new_test.exs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,27 @@ defmodule Mix.Tasks.NewTest do
145145

146146
test "new with invalid args" do
147147
in_tmp("new with an invalid application name", fn ->
148-
assert_raise Mix.Error, ~r"Application name must start with a letter and ", fn ->
149-
Mix.Tasks.New.run(["007invalid"])
150-
end
151-
152-
assert_raise Mix.Error, ~r"only lowercase letters, numbers and underscore", fn ->
153-
Mix.Tasks.New.run(["invAlid"])
154-
end
148+
assert_raise Mix.Error,
149+
~r"Application name must start with a lowercase ASCII letter",
150+
fn ->
151+
Mix.Tasks.New.run(["007invalid"])
152+
end
153+
154+
assert_raise Mix.Error,
155+
~r"followed by lowercase ASCII letters, numbers, or underscores",
156+
fn ->
157+
Mix.Tasks.New.run(["invAlid"])
158+
end
159+
160+
assert_raise Mix.Error,
161+
~r"followed by lowercase ASCII letters, numbers, or underscores",
162+
fn ->
163+
Mix.Tasks.New.run(["inválido"])
164+
end
155165
end)
156166

157167
in_tmp("new with an invalid application name from the app option", fn ->
158-
assert_raise Mix.Error, ~r"Application name must start with a letter and ", fn ->
168+
assert_raise Mix.Error, ~r"Application name must start with a lowercase ASCII letter", fn ->
159169
Mix.Tasks.New.run(["valid", "--app", "007invalid"])
160170
end
161171
end)

0 commit comments

Comments
 (0)