Skip to content

How can I test commands? #624

Answered by mrexox
goldingdamien asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you @EDMPhoenix! I just want to add that lefthook supports a few extra options for the lefthook run <hook> command.

Let's consider the following config:

pre-commit:
  commands:
    lint:
      run: yarn lint {staged_files}
      glob: "*.ts"
      root: "frontend/"

When you run lefthook run pre-commit the lint command will probably be skipped because there're no staged files matching the glob under the root. Instead you can do the following:

lefthook run pre-commit --force --commands lint --file frontend/index.js --file backend/main.go

Or if you want to pass all your files you can do this:

find . -type f -print0 | lefthook run pre-commit --force --commands lint --files-from-stdin

Se…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mrexox
Comment options

Answer selected by goldingdamien
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants