@karmaniverous/get-dotenv
    Preparing search index...

    Function formatDotenvValue

    • Internal

      Format a value as the token written after KEY=, so that dotenv's parse and then get-dotenv's expander read it back exactly.

      A $ the expander would act on (one that starts a reference, or follows a \) is written as \$, so the value is literal: a reference can't be written through this function. Forms of that text are tried in order and the first that dotenv reads back unchanged is used:

      • with preferQuote (the line's current quote style): that quote, then the other quotes (double, single, backtick), then bare;
      • without: bare, then double quotes, single quotes, backticks.

      Line breaks inside a quoted value are written in fileEol.

      Parameters

      • args: {
            fileEol?: "\n" | "\r\n";
            key: string;
            preferQuote?: DotenvQuote | null;
            value: string;
        }

        The key (for the error message), the value, the preferred quote style and the file EOL.

      Returns FormattedDotenvValue

      The token and the quote style it uses.

      Error when no form reads back unchanged (for example, a value that needs quotes and contains every quote character). The message names the key, never the value.