Project structure with node_modules on sub directory #347
Replies: 3 comments
-
Hey, there is a Assuming you have the following structure:
The configuration will look like this: # lefthook.yml
pre-commit:
commands:
lint:
root: "src/"
run: npx eslint --fix {staged_files} && git add {staged_files} You can provide your lefthook.yml, and I can debug it if something doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Thanks @mrexox! I didn't notice this option, but it seems to refer to the execution of a specific command or script. In my case, I would like to add lefthook as a project dependency, where dependencies live in Since the git toplevel directory is /, when the git-hook runs lefthook, it doesn't find the executable (in / there is no node_modules folder) and therefore reaches the last elif where npx install lefthook globally.
I hope I have explained. Here is the lefthook.yml file: pre-commit:
scripts:
"test.sh":
runner: bash |
Beta Was this translation helpful? Give feedback.
-
Hmm, what do you think of adding a |
Beta Was this translation helpful? Give feedback.
-
I have several projects where the node_modules folder doesn't live in the root of the project, but it's inside a sub-folder called "src".
While debugging I found that the call_lefthook method sets the
$dir
variable withgit rev-parse --show-toplevel
. This would look fornode_modules
inside the root, and if won't find it try to install it globally with npx.Maybe I'm wrong, but wouldn't it be more appropriate to search directly for the
node_modules
folder?Beta Was this translation helpful? Give feedback.
All reactions