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

Non-root package.json (working directory) causes duplicate directories in filepaths #3

Closed
erik-inkapool opened this issue Feb 5, 2018 · 3 comments · Fixed by #4
Closed
Labels
bug Something isn't working

Comments

@erik-inkapool
Copy link
Contributor

When running precise-commits from a subdirectory to the git directory the diff file paths will include some of the directories in the working directory causing ENOENT: no such file or directory errors.

I'll try to make a PR to fix this, it should be a simple change.

@JamesHenry
Copy link
Contributor

Thanks for reporting, @erik-lundgren! Please could you provide an example file tree for what you are describing? Just want to make sure I understand correctly.

@erik-inkapool
Copy link
Contributor Author

erik-inkapool commented Feb 6, 2018

The issue occurs because git diff, which is used by getModifiedFilenames in git-utils.ts (here) reports file paths from the root directory and working directory is wherever the package.json is located.

With the following file tree:

[root]
-- .git
-- myfolder
   -- package.json
   -- index.ts

You would get [root]/myfolder as working directory and myfolder/index.ts as filename on index.ts line 113. Joining those produces [root]/myfolder/myfolder/index.ts. I believe it could be fixed with this change by using the git root instead of the workingDirectory:

-    fullPath: join(workingDirectory, filename),
+    fullPath: join(gitDirectoryParent, filename),

I decided to hold off on using this as I couldn't quite get it to work locally even with my changes and npm link (likely because of user error).

I attempted to make a PR to fix it but tests were failing for me locally because of my auto-crlf settings and I couldn't get my typescript 2.7 to compile so I hope the information given above is enough for you to fix it at some point and then I can have another go at making it work for our repo. :) Sorry about the lack of the promised PR.

Strike that, here's a PR: #4

@JamesHenry
Copy link
Contributor

Thanks @erik-lundgren!

@JamesHenry JamesHenry added the bug Something isn't working label Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants