Closed eikowagenknecht closed 7 months ago
Thank you for the issue. I think the problem occurs because for windows the argument includes the quotes, while on Linux/macOS those quotes are treated differently because the actual command is wrapped with sh
. Currently I don't have a workaround for this issue, but I will try to figure it out.
"{staged_files}"
works, '{staged_files}'
causes the same error.
@eikowagenknecht , does wrapping {staged_files} in "
helps?
pre-commit:
parallel: false
commands:
eslint:
glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx}"
run: npx eslint "{staged_files}"
Indeed, "{staged_files}"
fixes it :-)
I'm closing this issue since there's a workaround found. Thank you, @wonu!
:wrench: Summary
Mostly the same as #303, but instead of
No files matching the pattern "some/path/to..tsx" were found.
I getNo files matching the pattern "'some/path/$file.tsx'" were found.
I'm using Windows.
Lefthook version
1.6.3 0845abb2105d2e6870744915df8445af00afd0c0
Steps to reproduce
$
in its name.lefthook.yml:
Expected results
File is processed.
Actual results
Possible Solution
It seems like there are too many quotes arount the staged files. From the console:
npx eslint 'src/routes/manage/$cardId.tsx'
-> worksnpx eslint "src/routes/manage/$cardId.tsx"
ornpx eslint src/routes/manage/$cardId.tsx
->No files matching the pattern "src/routes/manage/.tsx" were found.
Logs / Screenshots
I especially notice the line
[lefthook] executing: npx eslint 'src/routes/manage/$cardId.tsx'
, which is exactly what I run from the console. And there it works?This issue documents the problem for eslint only, but I have the same problem with Biome for example, where a " × The system cannot find the path specified. (os error 3)" error is thrown instead of the message eslint gives. For this as well, running
npx biome check --apply --no-errors-on-unmatched --files-ignore-unknown=true 'src/routes/manage/$cardId.tsx'
from the console works fine.The suggested workaround
does not work for me and only gives the error message
'node_modules' is not recognized as an internal or external command, operable program or batch file.