How do I run specific commands for specific projects in one git repository? #882
-
|
I have a git repository which contains two projects. One is an asp.net core web api, and the other is a frontend vue project. They are in separate directories under the main git repo directory. My understanding is that a hook is executed per repository, so for example, if I configure a pre-commit hooks, any file that is staged and about to be committed will be passed in {staged_files} to my configured commands. The problem is, if I want to run my linter only for the frontend vue app and not the .net core files if I have any modified. But my linter and its configuration is installed in the vue app's directory. How can I set up lefthook config to run the linter in the vue app directory ONLY when a file from that directory is staged? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
So, you want to run the linter only in a specific folder, right? You can use Example pre-commit:
commands:
lint:
root: vue # filter by directory
glob: "*.{ts,js}" # filter by glob
run: yarn lint {staged_files} |
Beta Was this translation helpful? Give feedback.
So, you want to run the linter only in a specific folder, right?
You can use
rootoption. Besides filtering by directory it also changes thepwdto the given directory, so if you have the following project structure, you can useyarn lint {staged_files}and it will be executed in thevuedirectory:Example
lefthook.ymlconfig