Add commit hook for building javascript

This commit is contained in:
Thomas Eizinger 2020-02-17 21:45:09 +11:00
parent 86de0f7a98
commit d1b539bccd
2 changed files with 19 additions and 0 deletions

15
.githooks/pre-commit Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
# This commit hook checks whether we ran `yarn build` when committed TypeScript files.
# For GitHub actions to work, we need to check the compiled JavaScript into VCS.
#
# This script can yield false positives in cases where you only make stylistic changes to the TypeScript code that don't result in changes to the compiled JavaScript code.
# It is your responsibility as a developer to then commit the changes with `git commit --no-verify` and simply skip this commit hook.
TS_FILES=$(git diff --staged --name-only | grep -c '.ts')
DIST_MODIFIED=$(git diff --staged --name-only | grep -c dist/index.js)
if [ $TS_FILES -gt 0 ] && [ $DIST_MODIFIED -eq 0 ] ; then
echo "You modified TypeScript files but apparently did not run 'yarn build'".
exit 1;
fi

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Commit hook for preventing dist/index.js to be out of date after modifying Typescript files.
## [1.1.0] - 2020-02-17
### Added