Skip to content

Commit

Permalink
Check whether clang-format is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmavr committed Feb 15, 2022
1 parent 5e0f08a commit ae857f5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/clang_format.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/bin/bash

script_dir=`cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd`
# This script formats the spacings in your code according
# to clang's standards

which clang-format > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "ERROR: clang-format is not installed\n"\
"Please install it to run this script."
exit 1
fi

script_dir=`cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd`
declare -a src_files=($script_dir/../main.cpp $script_dir/../include/*.hpp $script_dir/../src/*.cpp)
for s in "${src_files[@]}"; do
clang-format -i $s
done

0 comments on commit ae857f5

Please sign in to comment.