diff options
-rw-r--r-- | src/rlx_app_info.erl | 2 | ||||
-rw-r--r-- | src/rlx_config.erl | 4 | ||||
-rw-r--r-- | src/rlx_prv_overlay.erl | 11 | ||||
-rw-r--r-- | src/rlx_prv_release.erl | 4 | ||||
-rw-r--r-- | src/rlx_release.erl | 2 | ||||
-rw-r--r-- | src/rlx_state.erl | 12 | ||||
-rw-r--r-- | src/rlx_util.erl | 18 |
7 files changed, 31 insertions, 22 deletions
diff --git a/src/rlx_app_info.erl b/src/rlx_app_info.erl index 618b1e2..b3402d0 100644 --- a/src/rlx_app_info.erl +++ b/src/rlx_app_info.erl @@ -63,7 +63,7 @@ -record(app_info_t, {name :: atom(), original_vsn :: string(), vsn :: ec_semver:semver(), - dir :: file:name(), + dir :: binary(), link=false :: boolean(), active_deps=[]:: [atom()], library_deps=[] :: [atom()]}). diff --git a/src/rlx_config.erl b/src/rlx_config.erl index 3c3ba98..d18f5f1 100644 --- a/src/rlx_config.erl +++ b/src/rlx_config.erl @@ -324,10 +324,10 @@ merge_configs([{Key, Value} | CliTerms], ConfigTerms) -> end. parse_vsn(Vsn) when Vsn =:= semver ; Vsn =:= "semver" -> - {ok, V} = ec_git_vsn:vsn([]), + {ok, V} = ec_git_vsn:vsn(ec_git_vsn:new()), V; parse_vsn({semver, _}) -> - {ok, V} = ec_git_vsn:vsn([]), + {ok, V} = ec_git_vsn:vsn(ec_git_vsn:new()), V; parse_vsn({cmd, Command}) -> V = os:cmd(Command), diff --git a/src/rlx_prv_overlay.erl b/src/rlx_prv_overlay.erl index becdb32..71aca97 100644 --- a/src/rlx_prv_overlay.erl +++ b/src/rlx_prv_overlay.erl @@ -442,8 +442,8 @@ is_directory(ToFile0, ToFile1) -> end. --spec render_template(proplists:proplist(), iolist()) -> - ok | relx:error(). +-spec render_template(proplists:proplist(), binary()) -> + {ok, binary()} | relx:error(). render_template(OverlayVars, Data) -> case rlx_util:render(Data, OverlayVars) of {ok, IoData} -> @@ -452,6 +452,8 @@ render_template(OverlayVars, Data) -> ?RLX_ERROR({unable_to_render_template, Data, Reason}) end. +-spec write_template(proplists:proplist(), file:name(), file:name()) -> + ok | relx:error(). write_template(OverlayVars, FromFile, ToFile) -> case file:read_file(FromFile) of {ok, File} -> @@ -477,10 +479,11 @@ write_template(OverlayVars, FromFile, ToFile) -> ?RLX_ERROR({read_template, FromFile, Error}) end. +-spec render_string(proplists:proplist(), iolist()) -> + binary() | relx:error(). render_string(OverlayVars, Data) -> case rlx_util:render(Data, OverlayVars) of - {ok, IoList} -> - erlang:iolist_to_binary(IoList); + {ok, Bin} -> Bin; {error, Error} -> ?RLX_ERROR({render_failed, Data, Error}) end. diff --git a/src/rlx_prv_release.erl b/src/rlx_prv_release.erl index 5feb798..2af8acd 100644 --- a/src/rlx_prv_release.erl +++ b/src/rlx_prv_release.erl @@ -208,9 +208,7 @@ set_resolved(State, Release0, Pkgs) -> _:_ -> ?RLX_ERROR({release_erts_error, ErtsDir}) end - end; - {error, E} -> - ?RLX_ERROR({release_error, E}) + end end. get_realized_release(State, RelName, RelVsn) -> diff --git a/src/rlx_release.erl b/src/rlx_release.erl index 2dc6ce0..dc39e34 100644 --- a/src/rlx_release.erl +++ b/src/rlx_release.erl @@ -141,7 +141,7 @@ goals(#release_t{goals=Goals}) -> Goals. -spec realize(t(), [{app_name(), app_vsn()}], [rlx_app_info:t()]) -> - {ok, t()} | relx:error(). + {ok, t()}. realize(Rel, Pkgs0, World0) -> World1 = subset_world(Pkgs0, World0), process_specs(realize_erts(Rel), World1). diff --git a/src/rlx_state.erl b/src/rlx_state.erl index a26546d..6974d52 100644 --- a/src/rlx_state.erl +++ b/src/rlx_state.erl @@ -102,8 +102,8 @@ providers=[] :: [providers:t()], available_apps=[] :: [rlx_app_info:t()], default_configured_release :: {rlx_release:name() | undefined, rlx_release:vsn() |undefined} | undefined, - vm_args :: file:filename() | undefined, - sys_config :: file:filename() | undefined, + vm_args :: file:filename() | false | undefined, + sys_config :: file:filename() | false | undefined, overrides=[] :: [{AppName::atom(), Directory::file:filename()}], skip_apps=[] :: [AppName::atom()], exclude_apps=[] :: [AppName::atom()], @@ -262,19 +262,19 @@ cli_args(State, CliArgs) -> providers(#state_t{providers=Providers}) -> Providers. --spec vm_args(t()) -> file:filename() | undefined. +-spec vm_args(t()) -> file:filename() | false | undefined. vm_args(#state_t{vm_args=VmArgs}) -> VmArgs. --spec vm_args(t(), file:filename()) -> t(). +-spec vm_args(t(), undefined | false | file:filename()) -> t(). vm_args(State, VmArgs) -> State#state_t{vm_args=VmArgs}. --spec sys_config(t()) -> file:filename() | undefined. +-spec sys_config(t()) -> file:filename() | false | undefined. sys_config(#state_t{sys_config=SysConfig}) -> SysConfig. --spec sys_config(t(), file:filename()) -> t(). +-spec sys_config(t(), false | file:filename()) -> t(). sys_config(State, SysConfig) -> State#state_t{sys_config=SysConfig}. diff --git a/src/rlx_util.erl b/src/rlx_util.erl index c4251d4..efad792 100644 --- a/src/rlx_util.erl +++ b/src/rlx_util.erl @@ -160,11 +160,21 @@ wildcard(Path) when is_list(Path) -> Paths -> Paths end. +-spec render(binary() | iolist()) -> + {ok, binary()} | {error, render_failed}. render(Template) -> render(Template, []). -render(Template, Data) -> - {ok, bbmustache:render(ec_cnv:to_binary(Template), Data, [{key_type, atom}])}. +-spec render(binary() | iolist(), proplists:proplist()) -> + {ok, binary()} | {error, render_failed}. +render(Template, Data) when is_list(Template) -> + render(ec_cnv:to_binary(Template), Data); +render(Template, Data) when is_binary(Template) -> + case catch bbmustache:render(Template, Data, + [{key_type, atom}]) of + Bin when is_binary(Bin) -> {ok, Bin}; + _ -> {error, render_failed} + end. load_file(Files, escript, Name) -> {Name, Bin} = lists:keyfind(Name, 1, Files), @@ -220,7 +230,7 @@ symlink_or_copy(Source, Target) -> ok -> ok; {error, eexist} -> - ok; + {error, eexist}; {error, _} -> case os:type() of {win32, _} -> @@ -242,8 +252,6 @@ win32_symlink(Source, Target) -> ok. -spec cp_r(list(string()), file:filename()) -> 'ok'. -cp_r([], _Dest) -> - ok; cp_r(Sources, Dest) -> case os:type() of {unix, _} -> |