mirror of
https://github.com/status-im/nim-codex.git
synced 2025-02-01 05:27:18 +00:00
e5df8c50d3
* style: nph setup * chore: formates codex/ and tests/ folder with nph 0.6.1
17 lines
456 B
Bash
Executable File
17 lines
456 B
Bash
Executable File
#!/bin/sh
|
|
|
|
echo "Formatting changed files with pre-commit hook"
|
|
|
|
# Regexp for grep to only choose some file extensions for formatting
|
|
exts="\.\(nim\|nims\)$"
|
|
|
|
# Build nph lazily
|
|
make build-nph || (1>&2 echo "failed to build nph. Pre-commit formatting will not be done."; exit 0)
|
|
|
|
# Format staged files
|
|
git diff --cached --name-only --diff-filter=ACMR | grep "$exts" | while read file; do
|
|
echo "Formatting $file"
|
|
make nph/"$file"
|
|
git add "$file"
|
|
done
|