evilmartians / lefthook

Fast and powerful Git hooks manager for any type of projects.
MIT License
4.66k stars 211 forks source link

Paths with brackets parsed incorrectly in Windows environment #747

Closed mbacalan closed 2 months ago

mbacalan commented 2 months ago

:wrench: Summary

We're running biome as part of a pre-commit hook via lefthook. Trying to commit code with offending formatting results in error when the file has brackets in its path, but only on Windows.

On a Linux machine or WSL, the path passed to the Biome CLI is "src/orders/[order-id]/index.tsx" On a Windows machine, the path passed to the Biome CLI is "\'src/orders/[order-id]/index.tsx\'"

Initial bug report made to Biome: https://github.com/biomejs/biome/issues/3203

Lefthook version

1.6.16 14f712b3aca2b8c57a868ae2c6e2a029c1721203

Steps to reproduce

https://github.com/mbacalan/biome-brackets-bug

Expected results

Paths with brackets in them are passed correctly to Biome CLI

Actual results

Paths with brackets in them are passed incorrectly to Biome CLI

mrexox commented 2 months ago

Hey! Thank you for reporting the error. Unfortunately I don't have a Windows machine to reproduce the bug. But I hope that this comment may help you: https://github.com/evilmartians/lefthook/issues/651#issuecomment-2004250084.

Could you try wrapping {staged_files} in double quotes like "{staged_files}"?

mbacalan commented 2 months ago

Thanks, that seems to work.

mrexox commented 2 months ago

I will close this issue since it's fixable with double quotes wrapping.