Does not work correctly if there are multiple excludes
pvcresin opened this issue · 2 comments
pvcresin commented
🔧 Summary
As the title says.
(Thank you very much for support of multiple exclude
!)
Lefthook version
1.7.5 d7ae5f7
Steps to reproduce
Repository: https://github.com/pvcresin/lefthook-exclude-test
package.json
{
"devDependencies": {
"lefthook": "^1.7.5",
"prettier": "^3.3.3"
}
}
lefthook.yml
---
pre-commit:
parallel: true
commands:
format:
glob: "*.js"
# exclude: "b.js|c.js" # worked correctly
exclude:
- b.js
- c.js
run: |
echo {staged_files}
npx prettier --write {staged_files}
stage_fixed: true
If I try to commit a.js, b.js, c.js, I want to format only a.js by prettier.
exclude: “b.js|c.js” # worked correctly.
exclude: # did not seem to work correctly.
- b.js
- c.js
Expected results
exclude:
- b.js
- c.js
If I try to commit a.js, b.js, c.js, only a.js is formatted
Actual results
exclude:
- b.js
- c.js
If I try to commit a.js, b.js, c.js, all a.js, b.js, c.js are formatted. 😢
Possible Solution
It might be more correct to append if v did not match all globs
Logs / Screenshots
LEFTHOOK_VERBOSE=true git ...