Pre-commit fails when starter is not at root of git repo
arlobelshee opened this issue · 2 comments
I am managing several sites in a single git repo (unusual, but makes sense in this case). Thus, I cloned the starter into this_repo/sites/my-site/
.
The precommit link & tests don't work. They end up adding the root-relative path from git status
to the path of the gatsby root, which duplicates path elements. For example, it tries to do stuff with this_repo/sites/my-site/sites/my-site/src/css/styles.css
.
This happens with precommit tests, precommit lint, and would with anything else that does git interactions.
Additionally, when I try to commit with sourcetree, I get a failure inside of lint-staged. I assume this is also a case of passing in the subdirectory and expecting it to be root.
Error: fatal: Not a git repository: '.git'
at ChildProcess.<anonymous> (C:\...\sites\my-site\node_modules\staged-git-files\index.js:85:19)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5) C:\...\sites\my-site\node_modules\lint-staged\src\index.js:44
files.forEach((file) => {
^
TypeError: Cannot read property 'forEach' of undefined
at sgf (C:\...\sites\my-site\node_modules\lint-staged\src\index.js:44:19)
at C:\...\sites\my-site\node_modules\staged-git-files\index.js:13:13
at C:\...\sites\my-site\node_modules\staged-git-files\index.js:38:13
at ChildProcess.<anonymous> (C:\...\sites\my-site\node_modules\staged-git-files\index.js:88:9)
at ChildProcess.emit (events.js:180:13)
at maybeClose (internal/child_process.js:936:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
Interresting, it looks to be an error with lint-staged, that is normal I guess. For your case you can maybe put the hooking part on the root ;) So remove the precommit from the sub packages ;) Otherwise try to search if it’s a know issue directly on lint-staged