@@ -15,7 +15,7 @@ defmodule MixHelper do
15
15
end
16
16
17
17
def in_tmp ( which , function ) do
18
- path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) , to_string ( which ) ] )
18
+ path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) <> to_string ( which ) ] )
19
19
20
20
try do
21
21
File . rm_rf! ( path )
@@ -28,19 +28,22 @@ defmodule MixHelper do
28
28
29
29
def in_tmp_project ( which , function ) do
30
30
conf_before = Application . get_env ( :phoenix , :generators ) || [ ]
31
- path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) , to_string ( which ) ] )
31
+ path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) <> to_string ( which ) ] )
32
32
33
33
try do
34
34
File . rm_rf! ( path )
35
35
File . mkdir_p! ( path )
36
+
36
37
File . cd! ( path , fn ->
37
38
File . touch! ( "mix.exs" )
39
+
38
40
File . write! ( ".formatter.exs" , """
39
41
[
40
42
import_deps: [:phoenix, :ecto, :ecto_sql],
41
43
inputs: ["*.exs"]
42
44
]
43
45
""" )
46
+
44
47
function . ( )
45
48
end )
46
49
after
@@ -51,7 +54,7 @@ defmodule MixHelper do
51
54
52
55
def in_tmp_umbrella_project ( which , function ) do
53
56
conf_before = Application . get_env ( :phoenix , :generators ) || [ ]
54
- path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) , to_string ( which ) ] )
57
+ path = Path . join ( [ tmp_path ( ) , random_string ( 10 ) <> to_string ( which ) ] )
55
58
56
59
try do
57
60
apps_path = Path . join ( path , "apps" )
@@ -61,9 +64,11 @@ defmodule MixHelper do
61
64
File . mkdir_p! ( apps_path )
62
65
File . mkdir_p! ( config_path )
63
66
File . touch! ( Path . join ( path , "mix.exs" ) )
67
+
64
68
for file <- ~w( config.exs dev.exs test.exs prod.exs) do
65
69
File . write! ( Path . join ( config_path , file ) , "import Config\n " )
66
70
end
71
+
67
72
File . cd! ( apps_path , function )
68
73
after
69
74
Application . put_env ( :phoenix , :generators , conf_before )
@@ -94,13 +99,17 @@ defmodule MixHelper do
94
99
def assert_file ( file , match ) do
95
100
cond do
96
101
is_list ( match ) ->
97
- assert_file file , & ( Enum . each ( match , fn ( m ) -> assert & 1 =~ m end ) )
102
+ assert_file ( file , & Enum . each ( match , fn m -> assert & 1 =~ m end ) )
103
+
98
104
is_binary ( match ) or is_struct ( match , Regex ) ->
99
- assert_file file , & ( assert & 1 =~ match )
105
+ assert_file ( file , & assert ( & 1 =~ match ) )
106
+
100
107
is_function ( match , 1 ) ->
101
108
assert_file ( file )
102
109
match . ( File . read! ( file ) )
103
- true -> raise inspect ( { file , match } )
110
+
111
+ true ->
112
+ raise inspect ( { file , match } )
104
113
end
105
114
end
106
115
@@ -118,6 +127,7 @@ defmodule MixHelper do
118
127
def with_generator_env ( app_name \\ :phoenix , new_env , fun ) do
119
128
config_before = Application . fetch_env ( app_name , :generators )
120
129
Application . put_env ( app_name , :generators , new_env )
130
+
121
131
try do
122
132
fun . ( )
123
133
after
@@ -150,7 +160,8 @@ defmodule MixHelper do
150
160
def flush do
151
161
receive do
152
162
_ -> flush ( )
153
- after 0 -> :ok
163
+ after
164
+ 0 -> :ok
154
165
end
155
166
end
156
167
end
0 commit comments