Dotenv value formatting, shared by get-dotenv's two dotenv writers: the
format-preserving editor (editDotenvText/editDotenvFile) and the
outputPath (-o) writer. A value is written so that get-dotenv's read
path, dotenv's parse and then get-dotenv's expander, reads it back
exactly (#72). A $ the expander would act on is escaped as \$ first
(review 5916926264 #4); dotenv reads \$ verbatim in every form.
dotenv's parser has quirks a writer must respect: a bare value ends at the
first # and is trimmed; carriage returns in the source become line feeds;
inside double quotes \n and \r are expanded and nothing else is
unescaped (so \\ and \" stay as written); single quotes and backticks
unescape nothing; and a quote preceded by \ doesn't close a value, which
then runs on to a later line. Rather than re-implement those rules, each
candidate form is checked with dotenv's own parse (the parser get-dotenv
reads dotenv files with), and the first one that reads back unchanged, and
that the parser of editDotenvFile reads as the same single value, is
written.
Dotenv value formatting, shared by get-dotenv's two dotenv writers: the format-preserving editor (
editDotenvText/editDotenvFile) and theoutputPath(-o) writer. A value is written so that get-dotenv's read path, dotenv'sparseand then get-dotenv's expander, reads it back exactly (#72). A$the expander would act on is escaped as\$first (review 5916926264 #4); dotenv reads\$verbatim in every form.dotenv's parser has quirks a writer must respect: a bare value ends at the first
#and is trimmed; carriage returns in the source become line feeds; inside double quotes\nand\rare expanded and nothing else is unescaped (so\\and\"stay as written); single quotes and backticks unescape nothing; and a quote preceded by\doesn't close a value, which then runs on to a later line. Rather than re-implement those rules, each candidate form is checked with dotenv's ownparse(the parser get-dotenv reads dotenv files with), and the first one that reads back unchanged, and that the parser ofeditDotenvFilereads as the same single value, is written.