Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure in submodule due to filepath mixup #90

Closed
peter-meinhardt opened this issue Oct 14, 2019 · 5 comments
Closed

Failure in submodule due to filepath mixup #90

peter-meinhardt opened this issue Oct 14, 2019 · 5 comments

Comments

@peter-meinhardt
Copy link

I am using prettier and pretty-quick in both the main repository and the submodule. Both have their own package.json with a pre-commit hook defined. When using pretty-quick inside the submodule, I get an error. The fileservice tries to acces a directory where the root path of the submodule seems to be replaced by the root path of the main repository. For example:

Main repository is at /Users/peter.meinhardt/GIT/Customer/Project/, submodule is at /Users/peter.meinhardt/GIT/Customer/Project/projects/core-module. I try to commit a file inside the submodule at /Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/src/lib/elements/specific-element and will get the following error:

🔍  Finding changed files since git revision 7c9ea477.
🎯  Found 1 changed file.
fs.js:115
    throw err;
    ^

Error: ENOENT: no such file or directory, scandir '/Users/peter.meinhardt/GIT/Customer/Project/src/lib/elements/specific-element'
    at Object.readdirSync (fs.js:783:3)
    at traverseFolder (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:40340:18)
    at findRoot (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:40356:10)
    at maybeParse (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:40368:16)
    at editorconfigSyncNoCache (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:40381:35)
    at editorconfigSyncNoCache (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:36212:20)
    at /Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:42627:14
    at Array.map (<anonymous>)
    at _resolveConfig (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:42626:40)
    at Function.resolveConfig.sync (/Users/peter.meinhardt/GIT/Customer/Project/projects/core-module/node_modules/prettier/index.js:42662:12)
husky > pre-commit hook failed (add --no-verify to bypass)```
@cjanietz
Copy link
Contributor

I have the exact same issue and it stems from https://github.com/azz/pretty-quick/blob/master/src/scms/git.js#L8
Even though the submodule is the reference directory findUp checks in the directory above. I will submit a PR

cjanietz added a commit to cjanietz/pretty-quick that referenced this issue Oct 19, 2019
@azz
Copy link
Member

azz commented Oct 21, 2019

I'm not really understanding the fix, @cjanietz. I thought find-up would look in the submodule directory before searching up the FS tree?

@cjanietz
Copy link
Contributor

.git is not a directory but a file in a submodule, therefore its either checking locally or making findUp search for file and dir @azz

@cjanietz
Copy link
Contributor

cjanietz commented Nov 5, 2019

@azz Can we please get this sorted out? Anything else you would like different?

@azz
Copy link
Member

azz commented Nov 5, 2019

Sorry @cjanietz, missed the notification. Fixed in #90.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants