mirror of
https://github.com/actions-rs/toolchain.git
synced 2025-08-15 05:15:07 +00:00
Add commit hook for verifying that we transpiled the TypeScript code
This commit is contained in:
parent
7a5bf470a1
commit
08b0276e0f
15
.githooks/pre-commit
Executable file
15
.githooks/pre-commit
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This commit hook checks whether we ran `npm run 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 'npm run build'".
|
||||||
|
exit 1;
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user