refactor: clean up file system entry retrieval#112
refactor: clean up file system entry retrieval#112rolandjitsu merged 1 commit intoreact-dropzone:betafrom
Conversation
Pull Request Test Coverage Report for Build 11821216180Details
💛 - Coveralls |
|
Note this is just the beginning of the code cleanup, I'll be going through the code and refactoring it before releasing the new major so I have a better understanding of how the code works in case bugs arise. |
|
@rolandjitsu this one is ready to be reviewed, can I ask you to take a look at it? |
7a18051 to
cde031d
Compare
|
I see the coverage went down because the tests are not hitting a specific no-op case that did not exist before, let me add a test for that. |
cde031d to
648cd95
Compare
|
Ok, test added. Coverage is back at a 100%. |
rolandjitsu
left a comment
There was a problem hiding this comment.
The simplification of the directory traversal and the file entry reading is quite nice. Thanks for that. But the function calls are unnecessary.
648cd95 to
5a56aef
Compare
Signed-off-by: Jon Koops <jonkoops@gmail.com>
5a56aef to
cd5e990
Compare
|
@rolandjitsu I agree that |
|
@jonkoops I did leave some comments. Whenever you've got the time, have a look. |
|
Will do, I've been busy with some other tasks but I will make some time. |
|
@rolandjitsu left a reply to your comments (#112 (comment)) and resolved some of the other threads, as those were kind of becoming overlapping discussions about the same point. |
|
Thanks again for the thorough review @rolandjitsu! |
|
🎉 This PR is included in version 3.0.0-beta.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What kind of change does this PR introduce?
Did you add tests for your changes?
If relevant, did you update the documentation?
Summary
Cleans up the code that retrieves and processes file system entries so that the flow is easier to follow. This is done by wrapping methods such as
readEntries()andfile()and 'promisifying' their callback style to promises, which allows them to beawaited.Additionally, this PR re-structures the
fromDirEntry()function to use the above and uses awhileloop to drain the directory reader until there are no more entries to read. This simplifies the code and improves readability as it is no longer required to jump through various functions and manually manage the promise withresolve()andreject()calls.Type safety is also improved by adding proper type definitions to all the affected code.
Does this PR introduce a breaking change?
No
Other information
This is a cleanup, but also I am going through and selectively re-writing code to get more familiar with the code-base.