From c1edaf78241135d2f3aa1730705963f00caa26e8 Mon Sep 17 00:00:00 2001 From: Lam Ngoc Khuong Date: Fri, 7 Jun 2024 22:30:03 +0700 Subject: [PATCH] feat: fix husky script --- .husky/pre-commit | 9 ++++++--- .husky/pre-push | 8 +++++--- package.json | 10 +++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index a1f231e..56cb783 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,10 +3,13 @@ BRANCH=$(git rev-parse --abbrev-ref HEAD) REGEX="^(feature|bugfix|hotfix|release|merge)\.([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)$" -echo "Branch name: $BRANCH" +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' +echo "Branch name: ${GREEN}$BRANCH${NC}" if ! echo "$BRANCH" | grep -qE "$REGEX"; then - echo "Your commit was rejected due to branching name" - echo "Please rename your branch with '(feature|bugfix|hotfix|release|merge)(.?).' syntax" + echo "${RED}Your commit was rejected due to branching name" + echo "Please rename your branch with '(feature|bugfix|hotfix|release|merge)(.?).' syntax${NC}" exit 1 fi diff --git a/.husky/pre-push b/.husky/pre-push index e2fa0bf..e114163 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,10 +1,12 @@ #!/usr/bin/env sh - +GREEN='\033[0;32m' +BLUE='\033[0;34m' +NC='\033[0m' changed_files=$(git diff --name-only HEAD HEAD~ -- '*.ts' '*.js') if [ -n "$changed_files" ]; then - echo "Running tests due to changes in the following TS/JS files:" + echo "${BLUE}Running tests due to changes in the following TS/JS files:${NC}" echo "$changed_files" pnpm test else - echo "No TS/JS files have been changed. Skipping tests." + echo "${GREEN}No TS/JS files have been changed. Skipping tests.${NC}" fi diff --git a/package.json b/package.json index 48623e2..a0978ca 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,9 @@ "rxjs": "7.8.1" }, "devDependencies": { - "@commitlint/cli": "^19.3.0", - "@commitlint/config-conventional": "^19.2.2", - "@eslint/js": "^9.4.0", + "@commitlint/cli": "19.3.0", + "@commitlint/config-conventional": "19.2.2", + "@eslint/js": "9.4.0", "@nestjs/cli": "10.3.2", "@nestjs/schematics": "10.1.1", "@nestjs/testing": "10.3.9", @@ -45,9 +45,9 @@ "eslint": "9.4.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.1.3", - "husky": "^9.0.11", + "husky": "9.0.11", "jest": "29.7.0", - "lint-staged": "^15.2.5", + "lint-staged": "15.2.5", "prettier": "3.3.1", "source-map-support": "0.5.21", "supertest": "7.0.0",