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

Prevent unnecessary outer directory searches #1082

Merged
merged 2 commits into from
Jul 29, 2019
Merged

Prevent unnecessary outer directory searches #1082

merged 2 commits into from
Jul 29, 2019

Conversation

spiltcoffee
Copy link
Contributor

Fixes #645 and supersedes PR #772

Figured I'd have a crack at getting this fix in. I ran into this particular bug trying to run typedoc on a project on my phone (shout out to Termux while I'm here, amazing Android terminal).

I've cherry-picked two relevant commits from the branch for #772, with a few adjustments:

  • I dropped the changes to the specs, as they seemed unrelated to the failing test harnesses and to getting this working again. I figured I'd look further if the tests wouldn't pass, but on my computer and my phone the tests seem to pass now.
  • I fixed a bug in the refactored reachedTopDirectory function where it seemed that the check was accidentally inversed.
  • Fixed the merge issues via the cherry-picking process.

If there's any further issues with this PR, I'm happy to follow up and to try and fix them.

pro-src and others added 2 commits July 28, 2019 13:17
Without the added checks, every directory in a source path would be scanned even when the project files have already been found. This can cause avoidable permission errors and thus typedoc to break on out-of-the-box builds for the simplest of projects.

* Stops the search when readme.md and package.json are found.
* Stops the search when `--readme = none` and package.json is found.
While this commit was taken from the pro-src/master branch, I've
made some changes as appropriate:
- Dropped the specs changes as it seemed unrelated to the test failures
- Fixed bug in `reachedTopDirectory` where it appeared to be
  accidentally inversed
- Fixed merge issues
Copy link
Collaborator

@aciccarello aciccarello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Thanks for cleaning up this method!

}

let dirName = Path.resolve(Path.dirname(fileName));
while (!packageAndReadmeFound() && !reachedTopDirectory(dirName) && !visitedDirBefore(dirName)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads very clearly to me 👍

@aciccarello aciccarello merged commit 8ace3f5 into TypeStrong:master Jul 29, 2019
@spiltcoffee spiltcoffee deleted the directory-search-fix branch July 29, 2019 02:06
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

Successfully merging this pull request may close these issues.

Excessive file search up to the system root
2 participants