diff --git a/src/elvis.erl b/src/elvis.erl index eaa2865..8d52ade 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. @@ -217,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