-
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.
Fix pre-commit hook to handle errors and restore files if necessary
- Loading branch information
1 parent
0a0b6e0
commit a912054
Showing
1 changed file
with
8 additions
and
5 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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
#!/bin/sh | ||
|
||
# This script runs the 'npm run all' command | ||
exit_code=0 | ||
|
||
# Run the npm command | ||
npm run all | ||
|
||
# Check the exit status and handle errors if needed | ||
if [ $? -ne 0 ]; then | ||
echo "An error occurred while running 'npm run all'." | ||
exit 1 | ||
exit_code=1 | ||
fi | ||
|
||
# Check for any changes in the dist/ directory | ||
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then | ||
echo "The 'npm run all' command has modified the dist/ directory. Please run 'npm run all' locally and commit the changes." | ||
|
||
# Restore the files that changed after running 'npm run all' | ||
git restore --staged --worktree dist/index.js dist/index.js.map badges/coverage.svg | ||
exit 1 | ||
exit_code=1 | ||
fi | ||
|
||
# Restore the files that changed after running 'npm run all' | ||
git restore --staged --worktree dist/index.js dist/index.js.map badges/coverage.svg | ||
|
||
exit $exit_code |