lefthook icon indicating copy to clipboard operation
lefthook copied to clipboard

"The command line is too long." issue on Windows

Open ivancuric opened this issue 5 years ago • 6 comments

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 avatar Aug 02 '19 09:08 ivancuric

@ivancuric thank you for issue! How much files you try to commit?

Arkweid avatar Aug 04 '19 10:08 Arkweid

a lot :D It was a find+replace project wide for multiple issues.

ivancuric avatar Aug 04 '19 11:08 ivancuric

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.

Arkweid avatar Aug 04 '19 11:08 Arkweid

Guess I could. Husky did it quite nicer to be honest, with an array of commands. Using .yaml and && feels quite messy by comparison.

ivancuric avatar Aug 04 '19 15:08 ivancuric

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 :)

Arkweid avatar Aug 04 '19 19:08 Arkweid

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.

vkrol avatar May 14 '20 09:05 vkrol

@mrexox this issue can be closed since it's fixed by #541

pvds avatar Sep 17 '23 19:09 pvds

Right, thank you! Closing it. Must be fixed with version 1.4.10

mrexox avatar Sep 18 '23 07:09 mrexox