Further improve pre-commit hook

This commit is contained in:
RabsRincon
2017-12-11 09:20:12 +01:00
parent ce6d70f33c
commit ef95efc4ce
3 changed files with 18 additions and 10 deletions

View File

@@ -1,18 +1,30 @@
#!/bin/bash
against='HEAD'
printf "\033[0;32mRunning tests...\033[0m\n"
FORBIDDEN='console.log'
FILES_PATTERN='\.(js)(\..+)?$'
OUT=0
printf "\033[0;32mRunning tests...\033[0m\n"
# Do not commit forbidden elements
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && printf "Please unstage console.log before commiting\n\033[0;31mAborting commit\033[0m\n" && exit 1
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && printf "Please unstage ${FORBIDDEN} before committing\n\033[0;31mAborting commit\033[0m\n" && exit 1
make check
# Pass lint and mocha tests
CHECK_OUTPUT=`make check`
if [ $? -ne 0 ]
then
printf "%s\n" "${CHECK_OUTPUT}"
printf "\033[0;31mAborting commit\033[0m\n"
exit 1
fi
# Have normalized whitespaces
git diff-index --check --cached 'HEAD' --
if [ $? -ne 0 ]
then
printf "\033[0;31mAborting commit\033[0m\n"
exit 1
fi
printf "\033[0;32mTests pass!\033[0m\n"

View File

@@ -2,7 +2,6 @@
#commentedProperty=This is not expected
exampleProperty=value
emptyProperty=
unusable
numericPropertyPositive=42
numericPropertyZero=0
numericPropertyNegative=-11

View File

@@ -49,9 +49,6 @@ describe('Properties', () => {
it('Ignores commented out properties', () => {
should.equal(casesProps("commentedProperty"), undefined);
});
it('Handles non split properties', () => {
should.equal(casesProps("unusable"), undefined)
});
it('Understands positive integers', () => {
should.equal(casesProps("numericPropertyPositive"), 42);
});