feat: writeFileAtomic module#142
Conversation
|
Is this pulling in https://github.com/npm/write-file-atomic or is this a new novel implementation? |
|
@wraithgar if by pulling you mean directly use, then no it is not. But the implementation is based on the same logic. I write to a new temp file, and then replace. Related to #55 |
|
Hi @wraithgar, just checking if anyone has bandwidth to review this. Happy to make changes |
|
I think the idea was to bring in write-file-atomic since that is a package we maintain ourselves already. |
|
@wraithgar understood. I have updated my PR. this time i'm pulling in write-file-atomic as is. Let me know if you have any suggestions. I assume the README will have to be updated too? |
|
I think the idea is that we add it as a dependency. There is no need to duplicate it, it already exists as a package. |
|
@wraithgar let me make sure I understand what you're saying. Are you suggesting to add write-file-atomic as a dependency, import the module, and then export it? If yes, then should the imported module first be wrapped? what functionality is the wrapper expected to add? My current understanding of shifting the entire implementation comes from the open issue #55 which states that the functionality should be implemented here. Also I took reference of a similar issue #56 . This was about move-file, and it was closed after shifting the entire logic here with this PR. Subsequently, the move-file repository was archived. |
|
@muskaanshraogi sorry for the slow response here yes, add write-file-atomic as a runtime dep and re-export it from lib/index.js, no wrapper needed. the So reworking this would be:
|
Adds a crash-safe writeFileAtomic helper using temp file + rename pattern. Prevents partial writes in scenarios like process crashes or interruptions.
References
Related to #55