Skip to content

Commit

Permalink
Added husky settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
khalima committed Feb 10, 2025
1 parent 3189bd0 commit fdfbd53
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
1 change: 1 addition & 0 deletions public/themes/custom/hdbt_subtheme/.husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
14 changes: 14 additions & 0 deletions public/themes/custom/hdbt_subtheme/.husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Supported patterns:
# feature/PROJECT-1234-test-test
# PROJECT-1234-test-test
# PROJECT-1234_test_test
id=$(echo `git rev-parse --abbrev-ref HEAD` | sed -nE 's|([a-z]+/)?([A-Z]+-[0-9]+)(-.+)?(_.+)?|\2|p')

# only prepare commit message if pattern matched and jiraId was found
if [[ ! -z $id ]]; then
# $1 is the name of the file containing the commit message
# Prepend "ABCD-123: "
sed -i.bak -E "1s/^/${id}: /" $1
fi
12 changes: 12 additions & 0 deletions public/themes/custom/hdbt_subtheme/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# Define the hdbt_subtheme path relative to the Git root
SUBTHEME_DIR="public/themes/custom/hdbt_subtheme/src"

# Check if any staged file is inside the hdbt_subtheme
if git diff --cached --name-only | grep -q "^$SUBTHEME_DIR"; then
echo "Detected changes in hdbt_subtheme/src/, running lint..."
cd "$SUBTHEME_DIR" || exit 1
npm run lint
fi
15 changes: 7 additions & 8 deletions public/themes/custom/hdbt_subtheme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion public/themes/custom/hdbt_subtheme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"build": "webpack --progress --mode=production --config webpack.config.js",
"preinstall": "npx update-browserslist-db@latest",
"lint": "lint-staged",
"lint:js": "eslint --fix src/"
"lint:js": "eslint --fix src/",
"prepare": "cd ../../../.. && husky install public/themes/custom/hdbt_subtheme/.husky || true"
},
"dependencies": {
"@babel/core": "^7.23.2",
Expand Down

0 comments on commit fdfbd53

Please sign in to comment.