-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d42915
commit 514dee8
Showing
3 changed files
with
96 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/sh | ||
|
||
# This script is an example of how a pre-commit hook might be set up | ||
# to execute pre-commit scripts from @krauters/utils. | ||
# | ||
# Prerequisite: Make sure to install @krauters/utils and ts-node in your project | ||
# npm install --save-dev @krauters/utils ts-node | ||
|
||
RED='\033[1;31m' | ||
GREEN='\033[1;32m' | ||
NC='\033[0m' | ||
|
||
PREFIX='[CHECKS]' | ||
|
||
log() { | ||
echo '${GREEN}${PREFIX}${NC} $1' | ||
} | ||
|
||
error() { | ||
echo '${RED}${PREFIX}${NC} $1' | ||
} | ||
|
||
log 'Running pre-commit scripts...' | ||
|
||
if ! OUTPUT=$(npx ts-node ./node_modules/@krauters/utils/src/scripts/pre-commit.ts 2>&1); then | ||
error "Pre-commit check failed:\n\n${OUTPUT}\n" | ||
error 'Aborting commit.' | ||
error 'Run commit with '-n' to skip pre-commit hooks.' | ||
exit 1 | ||
fi | ||
|
||
log "Script output...\n\n${OUTPUT}\n" | ||
log 'Pre-commit checks passed.' | ||
exit 0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters