Closed
Conversation
Contributor
Author
|
See #22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change greatly simplifies the operation of write-file-atomic, while also maintaining all functionality. It eliminates the dependency on slide-flow-control and replaces it with promises (I have a PR for that one too! isaacs/slide-flow-control#10)
Everything related to writeFile has been condensed into a single function with a single promise chain, and is very easy to read and follow.
I did this because I felt the nested callbacks pattern was overly complicated. I found it difficult to understand what was going on while investigating the following issue (and wrestling with this problem in my own project, not on github) :
I have a suspicion that these errors are caused on windows when a dependent package calls write-file-atomic multiple times on the same file, attempting to overwrite a file currently being written to. On Unix systems the behavior of fs.rename() simply replaces the file, but on Windows it is apparently more complicated! I have an idea on how to fix it and will make another pull request soon if it works.