Skip to content

Commit

Permalink
feat: fix husky script
Browse files Browse the repository at this point in the history
  • Loading branch information
lamngockhuong committed Jun 7, 2024
1 parent 5f75062 commit bbac644
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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)(.<ticket>?).<subject-example>' 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)(.<ticket>?).<subject-example>' syntax"
exit 1
fi

Expand Down
7 changes: 4 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit bbac644

Please sign in to comment.