-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a pre commit check for npm libraries
- Loading branch information
1 parent
fca136b
commit d5feb32
Showing
3 changed files
with
204 additions
and
58 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
LINT_CHECK_PATHS=( | ||
"Common/" | ||
"Signalling/" | ||
"Frontend/library/" | ||
"Frontend/ui-library/" | ||
"SignallingWebServer/" | ||
) | ||
|
||
FAILURE=0 | ||
FAILED_PATHS=() | ||
|
||
for CHECK_PATH in "${LINT_CHECK_PATHS[@]}"; do | ||
STAGED_FILES=$(git diff --name-only --cached "$CHECK_PATH") | ||
|
||
# check if any of the npm packages have changes | ||
if [[ -n "$STAGED_FILES" ]]; then | ||
echo ${CHECK_PATH} has changes. Running lint... | ||
pushd $CHECK_PATH >/dev/null | ||
if ! npm run lint; then | ||
FAILURE=1 | ||
FAILED_PATHS+=("$CHECK_PATH") | ||
fi | ||
popd >/dev/null | ||
fi | ||
done | ||
|
||
if [[ $FAILURE -eq 1 ]]; then | ||
echo Linting failures in the following paths... | ||
for FAILED_PATH in "${FAILED_PATHS[@]}"; do | ||
echo " $FAILED_PATH" | ||
done | ||
exit 1 | ||
fi | ||
|
||
|
Oops, something went wrong.