From bbac6444c7b75725d9e8955b718c3506d9101922 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 | 8 +++++--- .husky/pre-push | 7 ++++--- package.json | 10 +++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index a1f231e..ef0e0cc 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -3,10 +3,12 @@ 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' +echo -e "${GREEN}Branch name: $BRANCH" 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 -e "${RED}Your commit was rejected due to branching name" + echo -e "${RED}Please rename your branch with '(feature|bugfix|hotfix|release|merge)(.?).' syntax" exit 1 fi diff --git a/.husky/pre-push b/.husky/pre-push index e2fa0bf..2d6e430 100644 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,10 +1,11 @@ #!/usr/bin/env sh - +GREEN='\033[0;32m' +BLUE='\033[0;34m' 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 -e "${BLUE}Running tests due to changes in the following TS/JS files:" echo "$changed_files" pnpm test else - echo "No TS/JS files have been changed. Skipping tests." + echo -e "${GREEN}No TS/JS files have been changed. Skipping tests." 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",