erplibre/script/maintenance/prettier_xml.sh
Mathieu Benoit 6e57b2584a [FIX] npm installation
- install npm locally instead of globaly
2023-12-02 14:14:23 -05:00

17 lines
883 B
Bash
Executable file

#!/usr/bin/env bash
# This will format all xml
# argument 1: directory or file to format
STR_ARG="'$*'"
if [[ "${STR_ARG}" = *"/data/"* ]]; then
# Need to keep width with data, else add corrupted string data
./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 "$@"
else
./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 "$@"
# 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 $@
fi
retVal=$?
if [[ $retVal -ne 0 ]]; then
echo "Error prettier-xml format"
exit 1
fi