forked from square/spacecommander
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat-objc-file-dry-run.sh
More file actions
executable file
·33 lines (29 loc) · 1.14 KB
/
format-objc-file-dry-run.sh
File metadata and controls
executable file
·33 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
# format-objc-file-dry-run.sh
# Outputs a formatted Objective-C file to stdout (doesn't alter the file).
# Copyright 2015 Square, Inc
export CDPATH=""
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
if which python >&/dev/null; then
PYTHON=`which python`
elif which python3 >&/dev/null; then
PYTHON=`which python3`
else
echo "Either python or python3 is required to run this script"
exit 1
fi
# "#pragma Formatter Exempt" or "// MARK: Formatter Exempt" means don't format this file.
# Read the first line and trim it.
line="$(head -1 "$1" | xargs)"
if [ "$line" == "#pragma Formatter Exempt" -o "$line" == "// MARK: Formatter Exempt" ]; then
cat "$1" && exit 0
fi
cat "$1" | \
"$PYTHON" "$DIR"/custom/LiteralSymbolSpacer.py | \
"$PYTHON" "$DIR"/custom/InlineConstructorOnSingleLine.py | \
"$PYTHON" "$DIR"/custom/MacroSemicolonAppender.py | \
"$DIR"/bin/clang-format-3.8-custom -style=file | \
"$PYTHON" "$DIR"/custom/GenericCategoryLinebreakIndentation.py | \
"$PYTHON" "$DIR"/custom/ParameterAfterBlockNewline.py | \
"$PYTHON" "$DIR"/custom/HasIncludeSpaceRemover.py | \
"$PYTHON" "$DIR"/custom/NewLineAtEndOfFileInserter.py