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() {
local acc=()
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
echo $acc
echo ${acc[@]}
}
noisy() {
@ -19,5 +19,5 @@ noisy() {
acc+=("jsfile")
fi
done
echo $acc
echo ${acc[@]}
}

View file

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