knowledge-base
Yusheng’s personal knowledge base.
Format
Install prettier 1
npm install --global prettierPre-commit Hook 2
.git/hooks/pre-commit
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs prettier --ignore-unknown --write
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
exit 0Give it execute permission:
chmox +x .git/hooks/pre-commit.git/hooks/post-commit
#!/bin/sh
git update-index -gGive it execute permission:
chmox +x .git/hooks/post-commitRef: