From 11dc184e0198b4dfcaf8a10f46b58d03436b8804 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 24 Apr 2021 20:39:27 -0300 Subject: [PATCH] perf(husky): do not run checks if folder wasn't changed --- .husky/pre-commit | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index e38b205ae..1f5cbfeee 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -6,14 +6,29 @@ . "$(dirname "$0")/_/husky.sh" -cd tooling/api -yarn format -yarn lint-fix +if [ -z "$(git diff --name-only tooling/api)" ]; then + echo "skipping api - no changes detected" +else + cd tooling/api + yarn format + yarn lint-fix + cd ../.. +fi -cd ../cli.js -yarn format -yarn lint-fix +if [ -z "$(git diff --name-only tooling/cli.js)" ]; then + echo "skipping cli.js - no changes detected" +else + cd tooling/cli.js + yarn format + yarn lint-fix + cd ../.. +fi -cd ../create-tauri-app -yarn format -yarn lint-fix +if [ -z "$(git diff --name-only tooling/create-tauri-app)" ]; then + echo "skipping create-tauri-app - no changes detected" +else + cd tooling/create-tauri-app + yarn format + yarn lint-fix + cd ../.. +fi