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:
1 parent
f524867216
commit
fd29bfc7c5
1 file changed
+2
-2
+2
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user