blob: 1d7c46020a1cb5111657b87d00dfb35dd14a4cab (
plain)
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
34
35
36
37
|
# CI/Developer script to format
# Relies on Tidy - https://github.com/htacg/tidy-html5
# Autoformats Android XML files
function tidy-up-android-xml {
tidy -xml \
-m \
-i \
-w 100 \
-utf8 \
--quiet yes \
--indent-attributes yes \
--indent-spaces 4 \
--literal-attributes yes \
android/app/src/main/AndroidManifest.xml \
android/app/src/main/res/anim*/*.xml \
android/app/src/main/res/drawable*/*.xml \
android/app/src/main/res/layout*/*.xml \
android/app/src/main/res/values/*.xml
# FIXME - when tidy learns to not leave whitespace around, remove the line below - https://github.com/htacg/tidy-html5/issues/864
find android/app/src/main/ -name '*.xml' -exec sed -i -e 's/[ \t]*$//' '{}' ';'
}
# Autoformats Android XML files and returns 0 if no files were actually changed, or 1 if files were changed
function tidy-verify-xml {
tidy-up-android-xml
if git diff --exit-code -- android/app/src/main/AndroidManifest.xml android/app/src/main/res; then
echo "Android XML files are correctly formatted"
return 0
else
echo "android/app/src/main contains files that were changed, XML is not formatted properly"
return 1
fi
}
|