From 5968090f502cead8a6368bf8182f07186be03b35 Mon Sep 17 00:00:00 2001 From: Brikaa Date: Sun, 10 Oct 2021 16:56:16 +0200 Subject: [PATCH] Improve precommit --- piston | 15 ++++++++++++--- pre-commit | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/piston b/piston index 90d47ed..068895b 100755 --- a/piston +++ b/piston @@ -11,6 +11,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 ===" @@ -55,14 +62,16 @@ case $1 in restart) docker_compose restart ;; start) - rm -f .git/hooks/pre-commit - ln -s $(realpath $(dirname "$0"))/pre-commit .git/hooks/pre-commit + init_precommit docker_compose up -d ;; 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 diff --git a/pre-commit b/pre-commit index f592c88..288a5e3 100755 --- a/pre-commit +++ b/pre-commit @@ -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