@@ -26,20 +26,34 @@ defmodule Mix.Tasks.Deps.Partition do
2626 { :ok , { _ip , port } } = :inet . sockname ( socket )
2727 ansi_flag = if IO.ANSI . enabled? ( ) , do: ~c" --color" , else: ~c" --no-color"
2828 force_flag = if force? , do: ~c" --force" , else: ~c" --no-force"
29+ config = Mix.ProjectStack . peek ( ) |> :erlang . term_to_binary ( ) |> Base . url_encode64 ( )
30+ tmp_dir = System . tmp_dir ( )
31+
32+ { config_flag , config_value } =
33+ with true <- is_binary ( tmp_dir ) ,
34+ partition_dir = Path . join ( tmp_dir , "mix_deps_partition" ) ,
35+ :ok <- File . mkdir_p ( partition_dir ) ,
36+ partition_file = Path . join ( partition_dir , Base . encode32 ( :crypto . strong_rand_bytes ( 10 ) ) ) ,
37+ :ok <- File . write ( partition_file , config ) do
38+ { ~c" --config-file" , String . to_charlist ( partition_file ) }
39+ else
40+ _ -> { ~c" --config" , String . to_charlist ( config ) }
41+ end
2942
30- args = [
31- ansi_flag ,
32- ~c" -e" ,
33- ~c" Mix.Tasks.Deps.Partition.client" ,
34- ~c" --" ,
35- force_flag ,
36- ~c" --port" ,
37- Integer . to_charlist ( port ) ,
38- ~c" --host" ,
39- ~c" 127.0.0.1" ,
40- ~c" --config" ,
41- Mix.ProjectStack . peek ( ) |> :erlang . term_to_binary ( ) |> Base . url_encode64 ( )
42- ]
43+ args =
44+ [
45+ ansi_flag ,
46+ ~c" -e" ,
47+ ~c" Mix.Tasks.Deps.Partition.client" ,
48+ ~c" --" ,
49+ force_flag ,
50+ ~c" --port" ,
51+ Integer . to_charlist ( port ) ,
52+ ~c" --host" ,
53+ ~c" 127.0.0.1" ,
54+ config_flag ,
55+ config_value
56+ ]
4357
4458 options = [
4559 :exit_status ,
@@ -55,6 +69,10 @@ defmodule Mix.Tasks.Deps.Partition do
5569 ]
5670 ]
5771
72+ if Mix . debug? ( ) do
73+ IO . puts ( "-> mix deps.partition args: #{ Enum . join ( args , " " ) } " )
74+ end
75+
5876 ports =
5977 Map . new ( 1 .. count // 1 , fn index ->
6078 if Mix . debug? ( ) do
@@ -215,7 +233,14 @@ defmodule Mix.Tasks.Deps.Partition do
215233
216234 ## Client
217235
218- @ switches [ port: :integer , host: :string , force: :boolean , index: :string , config: :string ]
236+ @ switches [
237+ port: :integer ,
238+ host: :string ,
239+ force: :boolean ,
240+ index: :string ,
241+ config: :string ,
242+ config_file: :string
243+ ]
219244
220245 def client do
221246 # If stdin closes, we shutdown the VM
@@ -226,7 +251,15 @@ defmodule Mix.Tasks.Deps.Partition do
226251
227252 args = System . argv ( )
228253 { opts , [ ] } = OptionParser . parse! ( args , strict: @ switches )
229- peek = Keyword . fetch! ( opts , :config ) |> Base . url_decode64! ( ) |> :erlang . binary_to_term ( )
254+
255+ peek =
256+ if config_file = Keyword . get ( opts , :config_file ) do
257+ File . read! ( config_file )
258+ else
259+ Keyword . fetch! ( opts , :config )
260+ end
261+ |> Base . url_decode64! ( )
262+ |> :erlang . binary_to_term ( )
230263
231264 # This is specific to Mix.install/2 and how it handles compile-time config
232265 if compile_config = peek . config [ :compile_config ] do
0 commit comments