mirror of
https://github.com/ankidroid/Anki-Android.git
synced 2024-09-19 19:42:17 +02:00
Fix prettier throwing errors (#12895)
* Fix prettier throwing errors * Don't run prettier if there is not JS modified files Now pre-commit can be faster and throw less errors
This commit is contained in:
parent
9d7aa468a7
commit
c15cc962aa
12
pre-commit
12
pre-commit
@ -55,8 +55,14 @@ runPrettier () {
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run prettier over all Javascript files
|
CHANGED_JS_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.js/ { print $2 }')"
|
||||||
npx --yes prettier --ignore-unknown --write AnkiDroid/**/*.js
|
if [ -z "$CHANGED_JS_FILES" ]; then
|
||||||
|
echo "No Javascript staged files. Hence, skipping pre-commit Prettier run."
|
||||||
|
return 0
|
||||||
|
fi;
|
||||||
|
|
||||||
|
# Prettify changed files
|
||||||
|
echo "$CHANGED_JS_FILES" | xargs npx prettier --ignore-unknown --write
|
||||||
|
|
||||||
echo "Completed npx prettier run."
|
echo "Completed npx prettier run."
|
||||||
echo "$CHANGED_JS_FILES" | while read -r file; do
|
echo "$CHANGED_JS_FILES" | while read -r file; do
|
||||||
@ -67,5 +73,5 @@ runPrettier () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runKtlint
|
runKtlint
|
||||||
runPrettier
|
runPrettier || :; # || to avoid cancelling the commit if there is an error with Prettier
|
||||||
echo "Completed the pre-commit hook."
|
echo "Completed the pre-commit hook."
|
||||||
|
Loading…
Reference in New Issue
Block a user