motdotla / dotenv-expand

Variable expansion for dotenv. Expand variables already on your machine for use in your .env file.
https://dotenvx.com
BSD 2-Clause "Simplified" License
953 stars 95 forks source link

Can this be used on existing env variables on the system (not via .env) #90

Closed NaikAayush closed 9 months ago

NaikAayush commented 1 year ago

The project description mentions "If you find yourself needing to expand environment variables already existing on your machine, then dotenv-expand is your tool."

And after my exploration it seems like it's not for already existing environment variables. Raising this issue for confirmation on the same, is the description supposed to be "If you find yourself needing to expand environment variables already existing on your machine, then dotenv-expand is NOT your tool."?

Or is there a way to use this for already existing environment variables.

ivandotv commented 1 year ago

I think this would work.

 expand({ ignoreProcessEnv: true, parsed: process.env })
motdotla commented 9 months ago

yes, you can do what @ivandotv detailed.

also, keep an eye on dotenvx. we are adding variable expansion to it soon https://github.com/dotenvx/dotenvx/issues/58. then you can wrap any server or command with dotenv. handy.