Open jcayzac opened 3 months ago
For macOS, Linux, FreeBSD the commands in run
are executed via sh -c
wrapper. On Windows commands are executed without a wrapper.
So, if you use unix-like systems you can use Bourne shell syntax including pipes, if
statements, &&
, etc. But if it's important for you to keep configuration runnable on Windows you should use simple commands. If you need to use scripts, you can specify them directly and choose the runner for them explicitly.
Will execution automatically stop at the first error?
Yes
I thought it was intuitive that commands should be one-liners, and scripts should live in a separate directory lefthook tracks. But it makes sense to write the docs about it, so thank you for creating this issue 🙏
:zap: Summary
As far as I could see, the
run
documentation doesn't explain what the value for that configuration is beyond a "command", nor how Lefthook actually runs it, e.g direct invocation, thoughsh
, throughbash
, etc.Value
It's really difficult to understand what kind of command can be used for
run
, e.g. can pipes|
be used? Or&&
and||
? Can the exit code$?
of a command be checked withif
? Are scripts even supported at all? What's the behavior of multiple lines (usingrun: |
)? Will execution automatically stop at the first error? etc…Behavior and configuration changes
Documenting the current behavior.