fix(io): honor CRLF option when saving text files in save() - #9187
Open
Pcmhacker-piro wants to merge 1 commit into
Open
Pcmhacker-piro wants to merge 1 commit into
Pcmhacker-piro wants to merge 1 commit into
Conversation
Contributor
Author
|
Hi @ksen0 @limzykenneth, could you please review this PR when you get a chance? It resolves #9141 by ensuring the CRLF parameter is respected in |
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.
Description
Resolves #9141
Root Cause
When calling
save()on text / string arrays:save()delegated tofn.saveStrings(args[0], args[1], args[2])without passingargs[3](isCRLF), discarding the CRLF option when passed assave(data, 'filename', 'txt', true).save(data, 'filename.txt', true)orsaveStrings(data, 'filename.txt', true)),_checkFileExtensionextracts the'txt'extension, and the boolean flag was passed asargs[2].saveStrings(list, filename, extension, isCRLF)receivedextension = trueandisCRLF = undefined, defaulting to LF (\n).Changes
fn.save()to forwardargs[3]tofn.saveStrings(args[0], args[1], args[2], args[3]).fn.saveStrings(), checkif (typeof extension === 'boolean') { isCRLF = extension; extension = undefined; }so passing(list, 'filename.txt', true)properly setsisCRLF = true.test/unit/io/files.jsverifying CRLF output for bothsave()(4-argument and 3-argument signatures) andsaveStrings()(extension omitted).Proof & Verification
Real Terminal Video (
asciinemarecording)Unit Tests Passing
PR Checklist
npm run lintpassesnpx vitest run test/unit/io/files.jspasses (all 21 unit tests pass)