We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b80726 commit 1239e91Copy full SHA for 1239e91
format-files.sh
@@ -1,5 +1,9 @@
1
#!/usr/bin/env bash
2
3
+set -euo pipefail
4
+
5
+MODE="${1:-default}"
6
7
PROJ_ROOT=$(dirname $0)
8
9
if ! type -p clang-format >/dev/null; then
@@ -21,7 +25,13 @@ else
21
25
exit 1
22
26
fi
23
27
28
+EXTRA_FLAGS=""
29
+if [[ "$MODE" == "check" ]]; then
30
+ echo "check mode enabled, not formatting files, only checking"
31
+ EXTRA_FLAGS="--dry-run --Werror"
32
+fi
33
24
34
find "${PROJ_ROOT}" -type f \
35
\( -name "*.cpp" -o -name "*.c" -o -name "*.hpp" -o -name "*.h" \) \
36
-not -path "${PROJ_ROOT}/build/*" \
- -print -exec clang-format --style=file -i '{}' \;
37
+ -print0 | xargs -0 clang-format $EXTRA_FLAGS --style=file --verbose -i
0 commit comments