1
0
Fork 0
docsearch/docs/scripts/precommit
Tim Carry abbca83a12
Auto lint content (#492)
* Auto fix linting in documentation Markdown on commit

* Auto lint content
2018-10-08 13:24:06 +02:00

23 lines
628 B
Bash
Executable file

#!/usr/bin/env sh
# This script is run before each commit on the repo and will try to fix linting
# issues of the documentation.
# This is run from ./docs folder, we need to go back to the git root to run the
# git methods
cd ../ || exit 1
# We only run the auto-fix when changes are actually made to markdown files
git diff --name-status master | grep '^\(.*\)docs/\(.*\).md$' 1>/dev/null
DOCS_FOLDER_HAS_CHANGED=$?
if [ "$DOCS_FOLDER_HAS_CHANGED" = "1" ]; then
exit 0
fi
echo "Markdown documentation updated."
echo "Running auto-lint..."
cd ./docs || exit 1
yarn run lint:md:fix
cd ../ || exit 1
git add ./docs/**/*.md