Dotenv: Comments & apostrophes

Created on 13 Nov 2018  Â·  5Comments  Â·  Source: motdotla/dotenv

I have such a row in my .env file:

REACT_APP_PLAID_MODE=sandbox # sandbox|development|production

And I get a REACT_APP_PLAID_MODE value, equal to:

sandbox # sandbox|development|production

instead of just:


Looks like there's no strict standards for this, each dotenv library vary from language to language. But it doesn't look like a normal behaviour. Look at Ruby's dotenv, etc. – they have it – you can use # for comments (not just for whole lines but for parts too), and ' & " symbols when need explicitly set a value (containing #)

All 5 comments

We loosely follow the INI file format which supports comments on dedicated lines (not inline)

# sandbox|development|production
REACT_APP_PLAID_MODE=sandbox

Being able to have lines like

REACT_APP_PLAID_MODE=sandbox # sandbox|development|production

Is extremely useful because it encourages adding some documentation about the configuration to the same line as the config. It's not uncommon for unattached comments to become separated from the thing they are meant to comment on, and it allows end users to sort the file alphabetically (which makes it easier to find configs and duplicates) without fear of losing comments.

Yep. Another argument for using this approach - it's already supported widely

For example, vscode:

image

@maxbeatty, people want that :)

This kind of smug comment makes me not want to spend my free time writing and maintaining software for others.

@maxbeatty Would you be open to a PR that adds support for inline comments?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

datasmurfen picture datasmurfen  Â·  5Comments

samayo picture samayo  Â·  3Comments

AndersDJohnson picture AndersDJohnson  Â·  5Comments

shellscape picture shellscape  Â·  3Comments

Vandivier picture Vandivier  Â·  3Comments