mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-22 09:41:26 -08:00
* Add intl pre-commit hook and update GHA - add Husky lib - add pre-commit script - detect warning on extraction and abort commit - update deploy staging yml to show message that en.json was modified * Test if block of message post - test if the message is posted even when checking a file with no changes * Add back in full deploy action * Add back en.json
41 lines
No EOL
1.4 KiB
Bash
Executable file
41 lines
No EOL
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
echo
|
|
echo "[pre-commit hook msg]: running pre-commit hook ..."
|
|
|
|
# Husky by default expects pre-commit hooks in the root directory. We set up a custom directory for the client folder
|
|
# https://typicode.github.io/husky/#/?id=custom-directory
|
|
cd client
|
|
|
|
# This file will automatically run intl:extract and compile on every commit
|
|
# write the extracted errors into a file
|
|
npm run intl:extract 2> extract-err.txt
|
|
|
|
# check the extracted error files for warnings and abort commit if found
|
|
if grep -F "warning" extract-err.txt
|
|
then
|
|
echo
|
|
echo '[pre-commit hook msg]: ALERT: warnings found in extraction process. Please remove warnings and re-run "npm run intl:extract"'
|
|
echo
|
|
echo '[pre-commit hook msg]: aborting commit...'
|
|
echo
|
|
echo '[pre-commit hook msg]: removing extract-err file...'
|
|
echo
|
|
rm extract-err.txt
|
|
echo '[pre-commit hook msg]: pre-commit hook incomplete.'
|
|
echo
|
|
exit 1
|
|
else
|
|
echo
|
|
echo '[pre-commit hook msg]: no warnings found, continuing with commit ...'
|
|
echo
|
|
echo '[pre-commit hook msg]: removing extract-err file ...'
|
|
echo
|
|
rm extract-err.txt
|
|
echo '[pre-commit hook msg]: adding en.json to staging area ...'
|
|
echo
|
|
# add the en.json to staging so that the pre-commit hook can include it in the commit
|
|
git add src/intl/en.json
|
|
echo '[pre-commit hook msg]: pre-commit hook complete.'
|
|
echo
|
|
fi |