From ff4cbea57137521d60dfa283cfc72c6989439257 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 24 Aug 2022 17:44:55 +0200 Subject: [PATCH] improvements for auto-formatter script --- scripts/auto-formatter.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/auto-formatter.sh b/scripts/auto-formatter.sh index c0ae7099c..723add4fe 100755 --- a/scripts/auto-formatter.sh +++ b/scripts/auto-formatter.sh @@ -3,6 +3,11 @@ if [[ ! -f README.md ]]; then cd .. fi +folder_list=( + "./src" + "./unittests" +) + cmake_fmt="cmake-format" file_selectors="-iname CMakeLists.txt" if command -v ${cmake_fmt} &> /dev/null; then @@ -15,8 +20,10 @@ fi cpp_format="clang-format" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" if command -v ${cpp_format} &> /dev/null; then - find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i - find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i + for dir in ${folder_list[@]}; do + echo "Auto-formatting ${dir} recursively" + find ${dir} ${file_selectors} | xargs clang-format --style=file -i + done else echo "No ${cpp_format} tool found, not formatting C++/C files" fi