Merge pull request #366 from Brikaa/pre-commit

Improve pre-commit
This commit is contained in:
Thomas Hobson 2021-10-13 23:17:52 +13:00 committed by GitHub
commit 8a89af7512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

13
piston
View File

@ -14,6 +14,13 @@ docker_compose(){
fi
}
init_precommit() {
if [ $PISTON_ENV == "dev" ]; then
rm -f .git/hooks/pre-commit
ln -s $(realpath $(dirname "$0"))/pre-commit .git/hooks/pre-commit
fi
}
case $1 in
help)
echo "=== Piston Management ==="
@ -59,6 +66,7 @@ case $1 in
restart) docker_compose restart ;;
start)
init_precommit
rm -f .git/hooks/pre-commit
ln -s "$PISTON_PATH/pre-commit" "$PISTON_PATH/.git/hooks/pre-commit"
docker_compose up -d
@ -66,7 +74,10 @@ case $1 in
stop) docker_compose down ;;
bash) docker_compose exec api /bin/bash ;;
rebuild) docker_compose build && docker_compose up -d ;;
rebuild)
init_precommit
docker_compose build && docker_compose up -d
;;
update)
git pull

View File

@ -1,7 +1,7 @@
#!/bin/sh
echo "Linting staged files..."
npm install
npm install > /dev/null || exit 1
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0