I want to ignore any dist
and node_modules
directories in my git commit hook. I've tried this:
git diff --cached --name-only --diff-filter=ACM | find . -path ./node_modules -prune -o -path './**/dist -prune -o -name '*.js'
But it doesn't work. It doesn't seem like the find is accepting the files found from the git diff...
If I run:
git diff --cached --name-only --diff-filter=ACM
I correctly get the staged files:
./dist/some-file.js
And if I run:
find . -path ./node_modules -prune -o -path './**/dist' -prune -o -name '*.js' -print
I correctly get a list of files that don't include any that are in dist
or node_modules
directories.
How can I combine these do that my git hook doesn't pick up staged files in dist directories.
find
doesn't process its standard input, so it can't be used after |
grep can be used instead
| grep -v '/dist/' | grep -v '/node_modules/'
or using one grep process
| grep -Ev '/dist/|/node_modules/'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.