Skip to content

Commit 53df56b

Browse files
committed
Add .local config
1 parent 27ec431 commit 53df56b

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Set .local/ directory to be treated specially in git
2+
/.local/ export-ignore

.local/jstest.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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

0 commit comments

Comments
 (0)