docs(precommit): Ignore unknown files (#10634)

Without `--ignore-unknown`, files without an extension or with an unknown extension would trigger the following error :
```
.gitignore[error] No parser could be inferred for file: ansible.cfg
```
This commit is contained in:
Jonas DOREL authored and GitHub committed 2021-03-29 13:50:36 +03:00
1 parent f524867216
commit fd29bfc7c5
1 file changed
+2 -2
+2 -2
View File
@@ -119,11 +119,11 @@ Alternately you can save this script as `.git/hooks/pre-commit` and give it exec
```sh
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR "*.js" "*.jsx" | sed 's| |\\ |g')
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs ./node_modules/.bin/prettier --write
echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add