@@ -30,7 +30,7 @@ defmodule Mix.Gleam do
3030 deps: deps ++ dev_deps
3131 }
3232 |> maybe_gleam_version ( json )
33- |> maybe_erlang_opts ( json )
33+ |> maybe_erlang_opts ( json [ "erlang" ] )
3434 rescue
3535 KeyError ->
3636 Mix . raise ( "Command \" gleam export package-information\" unexpected format: \n " <> json )
@@ -45,7 +45,7 @@ defmodule Mix.Gleam do
4545 { dep , version , opts }
4646
4747 % { "path" => path } ->
48- { dep , Keyword . merge ( opts , path: Path . expand ( path ) ) }
48+ { dep , Keyword . merge ( opts , path: path ) }
4949
5050 % { "git" => git , "ref" => ref } ->
5151 { dep , git: git , ref: ref }
@@ -67,17 +67,24 @@ defmodule Mix.Gleam do
6767 end
6868 end
6969
70- defp maybe_erlang_opts ( config , json ) do
71- config =
72- case get_in ( json , [ "erlang" , "application_start_module" ] ) do
73- nil -> config
74- mod -> Map . put ( config , :mod , mod )
75- end
70+ defp maybe_erlang_opts ( config , nil ) , do: config
7671
77- case get_in ( json , [ "erlang" , "extra_applications" ] ) do
78- nil -> config
79- extra_applications -> Map . put ( config , :extra_applications , extra_applications )
80- end
72+ defp maybe_erlang_opts ( config , opts ) do
73+ application =
74+ opts
75+ |> Enum . filter ( fn { _ , value } -> value != nil end )
76+ |> Enum . map ( fn
77+ { "application_start_module" , module } when is_binary ( module ) ->
78+ { :mod , { String . to_atom ( module ) , [ ] } }
79+
80+ { "extra_applications" , applications } when is_list ( applications ) ->
81+ { :extra_applications , Enum . map ( applications , & String . to_atom / 1 ) }
82+
83+ { key , value } ->
84+ IO . warn ( "Gleam [erlang] option not supported\n #{ key } : #{ inspect ( value ) } " )
85+ end )
86+
87+ Map . put ( config , :application , application )
8188 end
8289
8390 def require! ( ) do
0 commit comments