Add pre-commit hook and setup script (#129)
Add pre-commit hook and setup script Runs the appropriate linter on staged files before committing.
This commit is contained in:
parent
91779ccd03
commit
f639e3aa19
@ -23,7 +23,8 @@
|
||||
"lint:contracts": "solhint \"contracts/**/*.sol\" \"apps/*/contracts/**/*.sol\"",
|
||||
"lint:contract-tests": "eslint apps/*/test",
|
||||
"lint:wrapper": "eslint lib/",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"setup-git-hooks": "sh scripts/git-hooks/install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
2
scripts/git-hooks/install
Normal file
2
scripts/git-hooks/install
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
cp -f scripts/git-hooks/pre-commit .git/hooks
|
17
scripts/git-hooks/pre-commit
Executable file
17
scripts/git-hooks/pre-commit
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run appropriate linter against staged files
|
||||
#
|
||||
if [ $(git diff --name-only --cached lib/ | wc -l) != 0 ]; then
|
||||
./node_modules/.bin/eslint lib/
|
||||
if [ $? != 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
# TODO master not linted yet, uncomment this when ready
|
||||
# if [ $(git diff --name-only --cached contracts/ | wc -l) != 0 ]; then
|
||||
# solhint contracts/**/*.sol && apps/*/contracts/**/*.sol
|
||||
# if [ $? != 0 ]; then
|
||||
# exit 1
|
||||
# fi
|
||||
# fi
|
Loading…
x
Reference in New Issue
Block a user