Add commitlint support

This commit is contained in:
Michael Vines
2020-06-12 21:50:23 -07:00
parent 483fb86b06
commit f3965c3eb7
3 changed files with 46 additions and 6 deletions

32
.travis/commitlint.sh Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# Runs commitlint in the provided subdirectory
#
set -e
basedir=$1
if [[ -z "$basedir" ]]; then
echo "Usage: $0 [dir]"
exit 0
fi
if [[ ! -d "$basedir" ]]; then
echo "Error: not a directory: $basedir"
exit 1
fi
if [[ ! -f "$basedir"/commitlint.config.js ]]; then
echo "Error: No commitlint configuration found"
exit 1
fi
if [[ -z $TRAVIS_COMMIT_RANGE ]]; then
echo "Error: TRAVIS_COMMIT_RANGE not defined"
exit 1
fi
cd "$basedir"
while IFS= read -r line; do
echo "$line" | npx commitlint
done < <(git log "$TRAVIS_COMMIT_RANGE" --format=%s -- .)