node
node copied to clipboard
[--env-file] Space between = and " will cause the value to be parsed as an unquoted string
Meaning if you have this in your .env
file:
FOO= "BAR"
This command:
node --env-file=.env -e 'console.log({ FOO: process.env.FOO })'
Will print this:
{ FOO: '"BAR"' }
I.e. the variable value includes the quotes. (The spaces aren't included in the value, though.) I think this is unexpected.
If this is not intentional there needs to be white space skipping before this line:
https://github.com/nodejs/node/blob/9495a2bf1f20f853e90c8208741ad53448df986a/src/node_dotenv.cc#L153