File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ # Set .local/ directory to be treated specially in git
2+ /.local / export-ignore
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Define the pre-commit file path
4+ PRE_COMMIT_FILE=" ./javascriptv3/.husky/pre-commit"
5+
6+ # Check if an argument was provided
7+ if [ $# -ne 1 ]; then
8+ echo " Error: Please provide exactly one argument (on or off)"
9+ echo " Usage: $0 [on|off]"
10+ exit 1
11+ fi
12+
13+ # Check if the argument is valid
14+ if [ " $1 " != " on" ] && [ " $1 " != " off" ]; then
15+ echo " Error: Argument must be either 'on' or 'off'"
16+ echo " Usage: $0 [on|off]"
17+ exit 1
18+ fi
19+
20+ # Check if the pre-commit file exists
21+ if [ ! -f " $PRE_COMMIT_FILE " ]; then
22+ echo " Error: Pre-commit file not found at $PRE_COMMIT_FILE "
23+ exit 1
24+ fi
25+
26+ # Process the argument
27+ if [ " $1 " = " on" ]; then
28+ echo " Turning ON npm commands in pre-commit hook"
29+ # Remove comment symbols from lines starting with "# npm"
30+ sed -i ' s/^# npm/npm/g' " $PRE_COMMIT_FILE "
31+ echo " npm commands are now enabled in the pre-commit hook"
32+ elif [ " $1 " = " off" ]; then
33+ echo " Turning OFF npm commands in pre-commit hook"
34+ # Add comment symbols to lines starting with "npm"
35+ sed -i ' s/^npm/# npm/g' " $PRE_COMMIT_FILE "
36+ echo " npm commands are now disabled in the pre-commit hook"
37+ fi
38+
39+ exit 0
You can’t perform that action at this time.
0 commit comments