Git Hooks with stderr
For example, it’s tricky to validate a commit with pre-commit hook if an app does not return a proper exit code. Here’s a way to validate with the stderr.
- Make a temporary file
- Redirect stderr to the temp file
- Count the length of its content
You can understand it with code snippets below:
PowerShell
1 | $errFile = New-TemporaryFile |
Unix/Linux shell
1 | errFile = $(mktemp) |