From 770cf1d0229f895f45e709375aa09c0568c32dfa Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 26 Oct 2012 17:23:40 -0500 Subject: fix config file processing in relcool If only a single config is passed as part of the api then that was mishandled. This patch allows that situation to be detected and properly handled Signed-off-by: Jordan Wilberding --- src/rcl_state.erl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/rcl_state.erl b/src/rcl_state.erl index c326df1..46c91c7 100644 --- a/src/rcl_state.erl +++ b/src/rcl_state.erl @@ -85,13 +85,13 @@ %% API %%============================================================================ %% @doc Create a new 'log level' for the system --spec new(proplists:proplist(), [file:filename()]) -> t(). +-spec new(proplists:proplist(), [file:filename()] | file:filename()) -> t(). new(PropList, Targets) when erlang:is_list(PropList) -> State0 = #state_t{log = proplists:get_value(log, PropList, rcl_log:new(error)), output_dir=filename:absname(proplists:get_value(output_dir, PropList, "")), lib_dirs=get_lib_dirs(proplists:get_value(lib_dirs, PropList, [])), - config_files=handle_configs(Targets), + config_files=process_config_files(Targets), goals=proplists:get_value(goals, PropList, []), providers = [], releases=ec_dictionary:new(ec_dict), @@ -253,15 +253,15 @@ create_logic_providers(State0) -> ReleaseProvider, AssemblerProvider]}. -%% @doc explicitly handle single config file path --spec handle_configs(string() | [string()]) -> [string()]. -handle_configs(Configs = [Config | _]) - when erlang:is_list(Config) -> - Configs; -handle_configs(Config = [Char | _]) +%% @doc config files can come in as either a single file name or as a list of +%% files. We what to support both where possible. +process_config_files(File = [Char | _]) when erlang:is_integer(Char) -> - [Config]; -handle_configs([]) -> + [File]; +process_config_files(Files = [File | _]) + when erlang:is_list(File) -> + Files; +process_config_files([]) -> []. %%%=================================================================== -- cgit v1.2.3