fabien0102 / gatsby-starter

Gatsby 2.0 starter with typescript and many cools dev tools
386 stars 99 forks source link

Pre-commit fails when starter is not at root of git repo #57

Open arlobelshee opened 6 years ago

arlobelshee commented 6 years ago

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.

arlobelshee commented 6 years ago

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)
fabien0102 commented 6 years ago

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