Skip to content

Commit

Permalink
Adding a pre commit check for npm libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
mcottontensor committed Dec 19, 2024
1 parent fca136b commit d5feb32
Show file tree
Hide file tree
Showing 3 changed files with 204 additions and 58 deletions.
37 changes: 37 additions & 0 deletions Extras/Scripts/pre-commit-checks.sh
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


Loading

0 comments on commit d5feb32

Please sign in to comment.