2021-04-23 22:33:58 -04:00
|
|
|
#!/usr/bin/env bash
|
2024-02-23 13:01:10 -05:00
|
|
|
Red='\033[0;31m' # Red
|
|
|
|
|
Color_Off='\033[0m' # Text Reset
|
|
|
|
|
|
2021-04-23 22:33:58 -04:00
|
|
|
# This will format all xml
|
|
|
|
|
# argument 1: directory or file to format
|
2022-05-27 01:58:50 -04:00
|
|
|
STR_ARG="'$*'"
|
|
|
|
|
if [[ "${STR_ARG}" = *"/data/"* ]]; then
|
|
|
|
|
# Need to keep width with data, else add corrupted string data
|
2023-09-11 00:09:21 -04:00
|
|
|
./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 999999999 --write "$@"
|
2022-05-27 01:58:50 -04:00
|
|
|
else
|
2023-09-11 00:09:21 -04:00
|
|
|
./node_modules/.bin/prettier --plugin=@prettier/plugin-xml --xml-whitespace-sensitivity "ignore" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write "$@"
|
2023-04-09 18:41:27 -04:00
|
|
|
# strict xml-whitespace-sensitivity will keep space alignement
|
|
|
|
|
#prettier --xml-whitespace-sensitivity "strict" --prose-wrap always --tab-width 4 --no-bracket-spacing --print-width 120 --write $@
|
2022-05-27 01:58:50 -04:00
|
|
|
fi
|
2021-06-27 00:22:22 -04:00
|
|
|
retVal=$?
|
|
|
|
|
if [[ $retVal -ne 0 ]]; then
|
2024-02-23 13:01:10 -05:00
|
|
|
echo -e "${Red}Error${Color_Off} prettier-xml format"
|
2021-06-27 00:22:22 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|