Skip to content

Commit b91263f

Browse files
committed
Added development pre-commit hook
1 parent e8742d9 commit b91263f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ help:
4545
@echo "'LANG' argument is only required the first time until the exit command is executed."
4646
@echo
4747

48+
.git/hooks/pre-commit:
49+
@echo "#!/bin/sh\n\
50+
\n\
51+
if test -f \"./.langs\"; then\n\
52+
echo \"Error: You can't commit without exiting development mode.\\\n\\\n\\\\\
53+
\nTry the following command to exit development mode:\\\n\\\n\\\\\
54+
\n$$ make exit\\\n\" 1>&2;\n\
55+
exit 1\n\
56+
fi\n" > ./.git/hooks/pre-commit
57+
@chmod u+x ./.git/hooks/pre-commit
58+
4859
node_modules:
4960
@npm install
5061

@@ -56,7 +67,7 @@ check: package.json book.json LANGS.md
5667
false;\
5768
fi
5869

59-
setup: node_modules check
70+
setup: node_modules check .git/hooks/pre-commit
6071
@if ! test -f ".langs"; then\
6172
cp LANGS.md .langs && \
6273
echo "$(LANG_DATA)" > LANGS.md && \
@@ -85,7 +96,7 @@ mode:
8596
exit:
8697
@if test -f ".langs"; then\
8798
mv -f .langs LANGS.md && echo "Language file is restored";\
88-
rm -rf node_modules _book && echo "The project exited development mode.";\
99+
rm -rf node_modules _book .git/hooks/pre-commit && echo "The project exited development mode.";\
89100
fi
90101

91102
pdf:

0 commit comments

Comments
 (0)