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
955 stars 95 forks source link

Allow disabling `$xxx` expansion #83

Closed gustavotoyota closed 9 months ago

gustavotoyota commented 2 years ago

This feature would be very useful for me.

In CapRover the environment variables don't need a \ to mark dollar signs that aren't expansions, so whenever I have to move environment variables from CapRover to local I need to find all $ and add a \ before them, which is annoying and error-prone.

Also, this would allow variable expansion to be aligned with the usage of backticks in Javascript:

const MY_VAR = 123;

console.log(`hello$world`); // hello$world
console.log(`hello${MY_VAR}world`); // hello123world
console.log(`hello\${MY_VAR}world`); // hello${MY_VAR}world

While if I try the same in dotenv-expand:

MY_VAR=123

TEST1=hello$world # hello
TEST2=hello${MY_VAR}world # hello123world
TEST3=hello\${MY_VAR}world # hello${MY_VAR}world
scalp42 commented 1 year ago

@motdotla I see the same behavior, it prevents you from having any secret with a $.

motdotla commented 9 months ago

moving conversation here: https://github.com/motdotla/dotenv-expand/issues/101

it's an important one that we will get fixed up correctly and elegantly