pietvanzoen / deno-dotenv

Deprecated. Use std/dotenv instead.
https://deno.land/std/dotenv/
MIT License
148 stars 9 forks source link

Adding variables within .env files #46

Open aadamsx opened 3 years ago

aadamsx commented 3 years ago

Typically .env these files are small and manageable, but there are times when you run into situations where you duplicate the same data within the file. Here is an example:

MAIL_USERNAME=hello@laravel-news.com MAIL_FROM_ADDRESS=hello@laravel-news.com

The dotenv package that Laravel relies on can use variables with other defined variables in this same file. For example:

MAIL_USERNAME=hello@laravel-news.com MAIL_FROM_ADDRESS=${MAIL_USERNAME}

This simple trick allows you not to repeat yourself and can be useful when you have multiple services requiring the same piece of data.

I tried using this with the deno dotenv package and the engine doesn't pick up the variable, intead the console log value in the MAIL_FROM_ADDRESS example above would be ${MAIL_USERNAME} instead of hello@laravel-news.com.

pasha-bolokhov commented 2 years ago

This is a neat idea, and I don't mind looking into this, as this follows the general logic to enable some Shell functionality to those .env files. Obviously, not all functionality — but the ability to re–use variables is definitely worth considering:

BASE=/var/log/program
COMPONENT_LOG="${BASE}/component.log"
SERVER_LOG="${BASE}/server.log"

something along these lines