File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #! /usr/ bin
1+ #! /bin/bash
22
33set -e
44
55commit_msg=$( cat .git/COMMIT_EDITMSG)
6-
76echo " $commit_msg " | npx commitlint
Original file line number Diff line number Diff line change 1- #! /usr/ bin
1+ #! /bin/bash
22
33set -e
44
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Define the directory containing sample hooks
4+ SAMPLE_HOOKS_DIR=" .github/hooks"
5+
6+ # Define the target directory for Git hooks
7+ GIT_HOOKS_DIR=" .git/hooks"
8+
9+ # Function to copy or replace hooks
10+ copy_or_replace_hooks () {
11+ for hook in " $SAMPLE_HOOKS_DIR " /* ; do
12+ hook_name=$( basename " $hook " )
13+ target_hook=" $GIT_HOOKS_DIR /$hook_name "
14+ if [ -f " $target_hook " ]; then
15+ echo " Replacing existing hook: $hook_name "
16+ else
17+ echo " Copying new hook: $hook_name "
18+ fi
19+ cp " $hook " " $target_hook "
20+ chmod ug+x " $target_hook " # Ensure executable permission is set
21+ done
22+ }
23+
24+ # Main function
25+ main () {
26+ # Check if .git/hooks directory exists
27+ if [ ! -d " $GIT_HOOKS_DIR " ]; then
28+ echo " Error: .git/hooks directory not found. Are you in a Git repository?"
29+ exit 1
30+ fi
31+
32+ # Copy or replace hooks
33+ copy_or_replace_hooks
34+
35+ echo " Git hooks setup complete."
36+ }
37+
38+ # Run the main function
39+ main
Original file line number Diff line number Diff line change @@ -25,6 +25,10 @@ You can also try our NGX COPYPASTE [check](https://www.npmjs.com/package/ngx-cop
2525$ npm install --save ngx-loader-indicator
2626```
2727
28+ ## Setup hooks
29+ ``` bash
30+ $ npm run init:hooks
31+ ```
2832
2933## Quickstart if ngx-loader-indicator version >= 15.0.0
3034
Original file line number Diff line number Diff line change 2727 "lint:fix" : " ng lint --fix && npm run lint:scss:fix" ,
2828 "prettier:fix" : " npx prettier --write ." ,
2929 "type-coverage-report" : " typescript-coverage-report" ,
30- "type-coverage" : " type-coverage"
30+ "type-coverage" : " type-coverage" ,
31+ "init:git:hooks" : " .github/scripts/setup_hooks.sh"
3132 },
3233 "repository" : {
3334 "type" : " git" ,
You can’t perform that action at this time.
0 commit comments