Skip to content

Commit 23dc231

Browse files
committed
Updating format script to actually format the code and just display the issues with an argument
1 parent c876bab commit 23dc231

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

scripts/fmt.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22
# Used to format files to the given format using clang format.
3+
# example runs:
4+
# ./scripts/fmt.sh
5+
# ./scripts/fmt.sh format # This will write changes to file
6+
APPLY_FORMAT=${1:-""}
7+
38

49
# Variable that will hold the name of the clang-format command
510
FMT=""
@@ -20,6 +25,11 @@ if [ -z "$FMT" ]; then
2025
exit 1
2126
fi
2227

23-
files=$(find . \( -path ./build -prune -o -path ./.git -prune \) -o -type f -name "*[h|c]pp" -print)
28+
files=$(find . \( -path ./build -prune -o -path ./.git -prune -o -path ./third_party -prune \) -o -type f -name "*[h|c]pp" -print)
29+
30+
if [[ ${APPLY_FORMAT} = "format" ]]; then
31+
${FMT} -i ${files}
32+
else
33+
${FMT} --dry-run --Werror ${files}
34+
fi
2435

25-
${FMT} -i ${files}

0 commit comments

Comments
 (0)