forked from cloudspannerecosystem/autoscaler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update pre-commit to only run checks on affected files
- Loading branch information
Showing
1 changed file
with
29 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,33 @@ | ||
#!/bin/bash | ||
|
||
echo "Running .husky/pre-commit checks. Use -n/--no-verify to skip" | ||
echo "------------------------------------------------------------" | ||
|
||
npm run check-format | ||
npm run prettier-check | ||
npm run eslint | ||
npm run markdown-link-check | ||
npm run mdlint | ||
npm run typecheck | ||
npm run terraform-validate | ||
npm test | ||
|
||
function hasModifiedMatching() { | ||
[[ -z "$1" ]] && echo "hasModifiedMatching needs arg" && return 1 | ||
git status --short --untracked-files=all --column=never | grep -q "$1" | ||
return $? | ||
} | ||
|
||
# check for modified markdown? | ||
if hasModifiedMatching '\.md$' ; then | ||
echo "Markdown files modified... running checks" | ||
npm run markdown-link-check | ||
npm run mdlint | ||
fi | ||
|
||
if hasModifiedMatching ' src/' ; then | ||
echo "src files modified... running checks" | ||
npm run typecheck | ||
npm test | ||
fi | ||
|
||
|
||
if hasModifiedMatching '\.tf$' ; then | ||
echo "Terraform files modified... running checks" | ||
npm run terraform-fmt-check | ||
npm run terraform-validate | ||
fi |