From f61fc071218c75aff982196a527e2dc99807b686 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Thu, 29 Sep 2022 20:35:51 +0200 Subject: [PATCH] Fix: autodetect proper directories to format --- scripts/format_code.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/scripts/format_code.sh b/scripts/format_code.sh index d13a3036f..d88a712f7 100755 --- a/scripts/format_code.sh +++ b/scripts/format_code.sh @@ -1,17 +1,12 @@ #!/usr/bin/bash -# Print usage() if no argument given -if [ $# -eq 0 ] -then - echo "./format_code.sh MY_DIR_TO_FORMAT" - exit 1 -fi - -# Retrieve directory to parse -DIR=$1 +# Compute 'src' path +SCRIPT_DIR=$(dirname "$0") +REPO_DIR=$(readlink -f "$SCRIPT_DIR"/..) +DIRS="$REPO_DIR/src $REPO_DIR/include" # Apply formating to all *.cpp and *.h files -for FILE in `find "$DIR" -name '*.h' -o -name '*.cpp'` +for FILE in $(find $DIRS -name '*.h' -o -name '*.cpp') do echo $FILE clang-format -i -style=file "$FILE"