lefthook
lefthook copied to clipboard
"The command line is too long." issue on Windows
Running a script like
react-templates:
glob: '*.{jsx,tsx}'
run: >
npx eslint {staged_files} --fix &&
npx prettier {staged_files} --write &&
git add {staged_files}
when there are lots of files throws the The command line is too long
on Windows. Haven't had this issue with husky
@ivancuric thank you for issue! How much files you try to commit?
a lot :D It was a find+replace project wide for multiple issues.
Can you split commands in way like this without parallel
option?
1_react-templates-eslint:
glob: '*.{jsx,tsx}'
run: npx eslint {staged_files} --fix
2_react-templates-prettier:
glob: '*.{jsx,tsx}'
run: npx prettier {staged_files} --write
3_react-templates-add:
glob: '*.{jsx,tsx}'
run: git add {staged_files}
Looks like Windows can't process a large command.
Guess I could. Husky did it quite nicer to be honest, with an array of commands.
Using .yaml
and &&
feels quite messy by comparison.
Is it also happens if you run it under Windows SubSystem for Linux?
Using .yaml and && feels quite messy by comparison.
For run
option we want to have the same "natural" syntax as you see in your terminal. So that the user always understands exactly what is happening without any hidden processes. It's our tradeoff :)
FYI: It was fixed in lint-staged
via chunking https://github.com/okonet/lint-staged/pull/732. In theory, the same solution can be used in Lefthook.
@mrexox this issue can be closed since it's fixed by #541
Right, thank you! Closing it. Must be fixed with version 1.4.10