From efb0f056d096718e829d5c086591b01750865bd3 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Wed, 30 Mar 2022 13:54:18 -0700 Subject: [PATCH 1/2] Process command-line files according to config settings Previously, command-line files were forced to be processed sequentially, regardless of any `parallel` setting. Now the files are converted to elvis_files and included in the config for regular processing. --- src/elvis.erl | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/elvis.erl b/src/elvis.erl index eaa2865..4e8547e 100644 --- a/src/elvis.erl +++ b/src/elvis.erl @@ -143,15 +143,17 @@ process_options([], Cmds, Config) -> process_commands(Cmds, Config). -spec process_commands([string()], elvis_config:configs()) ->ok. +process_commands([rock], Config) -> + case elvis_core:rock(Config) of + {fail, _} -> elvis_utils:erlang_halt(1); + ok -> ok + end; process_commands([rock | Files], Config) -> - case Files of - [] -> - case elvis_core:rock(Config) of - {fail, _} -> elvis_utils:erlang_halt(1); - ok -> ok - end; - _ -> - lists:map(fun(F) -> rock_one_song(F, Config) end, Files) + Paths = [file_to_path(File) || File <- Files], + NewConfig = elvis_config:resolve_files(Config, Paths), + case elvis_core:rock(NewConfig) of + {fail, _} -> elvis_utils:erlang_halt(1); + ok -> ok end; process_commands([help | Cmds], Config) -> Config = help(Config), @@ -170,6 +172,16 @@ process_commands([], _Config) -> process_commands([_Cmd | _Cmds], _Config) -> throw(unrecognized_or_unimplemented_command). + +file_to_path(File) -> + Path = atom_to_list(File), + Dirname = filename:dirname(Path), + Filename = filename:basename(Path), + case elvis_file:find_files([Dirname], Filename) of + [] -> throw({enoent, Path}); + [File0] -> File0 + end. + %%% Options -spec help() -> ok. From 26ef5f27b4c2bca711e0623caf1d2c3127e5e4b8 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Thu, 31 Mar 2022 08:27:55 -0700 Subject: [PATCH 2/2] Remove unused function --- src/elvis.erl | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/elvis.erl b/src/elvis.erl index 4e8547e..8d52ade 100644 --- a/src/elvis.erl +++ b/src/elvis.erl @@ -229,17 +229,6 @@ version() -> "Elvis Core Version: ~s\n", io:format(Version, [ElvisShellVsn, ElvisCoreVsn]). -rock_one_song(FileName, Config) -> - F = atom_to_list(FileName), - case elvis_core:rock_this(F, Config) of - {fail, _} -> - case application:get_env(elvis_core, keep_rocking, false) of - false -> elvis_utils:erlang_halt(1); - true -> ok - end; - ok -> ok - end. - -spec default_config() -> elvis_config:configs(). default_config() -> default_config([ fun() -> elvis_config:from_file(?DEFAULT_CONFIG_PATH) end