File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change 2
2
" $( dirname " $0 " ) /_/husky.sh"
3
3
4
4
MATCH_PATH=' chaoscenter/web/'
5
+ STRINGS_FILE=" chaoscenter/web/strings/strings.en.yaml"
6
+
7
+ check_and_delete_unused_strings () {
8
+ TEMP_FILE=$( mktemp)
9
+ grep -rEo ' \b[a-zA-Z0-9_]+\b' chaoscenter/web/** /* .js > " $TEMP_FILE "
10
+ UNUSED_STRINGS=$( grep -v ' ^#' " $STRINGS_FILE " | grep -vFf " $TEMP_FILE " | grep -oE ' ^[a-zA-Z0-9_]+' )
11
+ rm " $TEMP_FILE "
12
+
13
+ if [ -n " $UNUSED_STRINGS " ]; then
14
+ echo " Unused strings found: $UNUSED_STRINGS "
15
+ for UNUSED_STRING in $UNUSED_STRINGS ; do
16
+ sed -i " /$UNUSED_STRING :/d" " $STRINGS_FILE "
17
+ done
18
+ echo " Unused strings deleted from $STRINGS_FILE "
19
+ else
20
+ echo " No unused strings found in $STRINGS_FILE "
21
+ fi
22
+ }
23
+
24
+ check_and_delete_unused_strings
5
25
6
26
BRANCH=$( git rev-parse --abbrev-ref HEAD)
7
27
8
- if [ " $BRANCH " = " main " ]; then
9
- echo " \033[0;31;1mYou can't commit directly to main branch\033[0m"
28
+ if [ " $BRANCH " = " master " ]; then
29
+ echo " \033[0;31;1mYou can't commit directly to master branch\033[0m"
10
30
exit 1
11
31
fi
12
32
@@ -24,4 +44,4 @@ if [ "$LITMUS_UI_FILE_CHANGES" -gt 0 ];
24
44
cd ./chaoscenter/web && yarn lint-staged
25
45
else
26
46
echo " \033[0;93mSkipping husky pre-commit hook in $MATCH_PATH folder\033[0m"
27
- fi
47
+ fi
You can’t perform that action at this time.
0 commit comments