Skip to content

Commit

Permalink
Merge pull request #379 from mcottontensor/npm-pre-commit
Browse files Browse the repository at this point in the history
Adding a pre commit check for npm libraries
  • Loading branch information
mcottontensor authored Dec 20, 2024
2 parents b47ac81 + a2f27e6 commit e12013f
Show file tree
Hide file tree
Showing 3 changed files with 223 additions and 77 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 e12013f

Please sign in to comment.