Skip to content

Instantly share code, notes, and snippets.

@takada-at
Created June 21, 2021 09:25
Show Gist options
  • Save takada-at/678ed712a01709cfc517872fe119af70 to your computer and use it in GitHub Desktop.
Save takada-at/678ed712a01709cfc517872fe119af70 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
EXIT_CODE=0
# `check $FILE_PATH $MESSAGE`: $FILE_PATH が存在してたら表示して EXIT_CODE を 1 に設定
function check () {
if [ -s $1 ]; then
echo $2
cat $1
EXIT_CODE=1
fi
}
rm -rf data/black.txt
black --check notes_generator 2>&1 1>/dev/null | grep "would reformat" > data/black.txt || true
black --check scripts 2>&1 1>/dev/null | grep "would reformat" >> data/black.txt || true
black --check tests 2>&1 1>/dev/null | grep "would reformat" >> data/black.txt || true
check data/black.txt '[check black]'
test $EXIT_CODE -eq 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment