Fix {pretty,lint} when staging more than one file

This commit is contained in:
Colin Caine 2018-05-21 15:30:36 +01:00
parent bc2abbb812
commit ad261b2e4f
2 changed files with 7 additions and 4 deletions

View file

@ -7,9 +7,9 @@ cachedJS() {
ugly() { ugly() {
local acc=() local acc=()
for jsfile in "$@"; do for jsfile in "$@"; do
diff "$jsfile" <($(npm bin)/prettier "$jsfile") >/dev/null || acc+=("$jsfile") diff "$jsfile" <($(npm bin)/prettier $jsfile) >/dev/null || acc+=("$jsfile")
done done
echo $acc echo ${acc[@]}
} }
noisy() { noisy() {
@ -19,5 +19,5 @@ noisy() {
acc+=("jsfile") acc+=("jsfile")
fi fi
done done
echo $acc echo ${acc[@]}
} }

View file

@ -2,8 +2,11 @@
source ./scripts/common source ./scripts/common
set -e
uglyFiles=$(ugly $(cachedJS)) uglyFiles=$(ugly $(cachedJS))
if [ -n "$uglyFiles" ]; then if [ -n "$uglyFiles" ]; then
prettier --write "$uglyFiles" prettier --write $uglyFiles
git add $uglyFiles
fi fi