-
I am using the following snippet to load a YAML formatted file, then immediately save it elsewhere: const fileContents = fs.readFileSync('./file.old', 'utf-8');
const document = yaml.parseDocument(fileContents, {keepSourceTokens: true});
fs.writeFile('./file.new', document.toString(), () => {}); However, when I compare the input and output diff file.old file.new I see that it does not preserve the whitespace and formatting of my original file
Is there a way to ensure that the stringified output is exactly the same as the parsed input? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
eemeli
Dec 8, 2023
Replies: 1 comment
-
For that you'll need to work with the CST API, as the Document level does not preserve whitespace. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jdvne
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
For that you'll need to work with the CST API, as the Document level does not preserve whitespace.