[TOOL] CS-fixer does not accept a list of files, so we need to run it on each file individually

This commit is contained in:
Hugo Sales 2021-12-26 15:13:37 +00:00 committed by Diogo Peralta Cordeiro
parent c79b1e4c94
commit 97243151fa
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
3 changed files with 7 additions and 12 deletions

View File

@ -46,7 +46,7 @@ test: tooling-docker
docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh $(call args,'')
cs-fixer: tooling-docker
@bin/php-cs-fixer $(call args,'')
@bin/php-cs-fixer $${CS_FIXER_FILE}
doc-check: tooling-docker
bin/php-doc-check

View File

@ -2,9 +2,8 @@
. bin/translate_container_name.sh
if [ "${#}" -eq 1 ]; then
docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -q -n --config=".php-cs-fixer.php" fix "${1}"
else
echo running without specific files?
if [ "$#" -eq 0 ] || [ -z "$*" ]; then
docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -n --config=".php-cs-fixer.php" fix
else
docker exec "$(translate_container_name tooling_php_1)" sh -c "/var/www/social/vendor/bin/php-cs-fixer -q -n --config=\".php-cs-fixer.php\" fix --path-mode=intersection -- $*"
fi

View File

@ -6,19 +6,15 @@ root="$(git rev-parse --show-toplevel)"
staged_files="$(git status --porcelain | sed -rn "s/^[^ ][ ] (.*)/\1/p")"
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_CS_FIX?}") 2>/dev/null); then
files=""
echo "Running php-cs-fixer on edited files"
for staged in ${staged_files}; do
# work only with existing files
if [ -f "${staged}" ] && expr "${staged}" : '^.*\.php$' > /dev/null; then
# use php-cs-fixer and get flag of correction
files="${staged} ${files}"
CS_FIXER_FILE="${staged}" make cs-fixer
git add "${staged}"
fi
done
if [ -n "${files}" ]; then
echo "Running php-cs-fixer on edited files"
make cs-fixer "${files}"
git add "${files}"
fi
fi
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_DOC_CHECK?}") 2>/dev/null); then