-
-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orthogonal Environment Variables #101
Conversation
My sentiments as well Love the changelog I'm going to think on this. @jcblw let's get your thoughts too. @maxbeatty this is nicely proposed. |
Im down for this I think we start encouraging people to start building things ontop of dotenv rather then wanting the functionality inside of dotenv. Maybe along with the bump we should try try to formalize the way to integrate things like variable expansion into dotenv. The same way we added the way to load the eg. // kinda works like arr.map
function variableExpansion (key, value, keyValues) {
...
return newValue;
}
dotenv.config({mapValues:[variableExpansion]}); |
We could return the parsed object instead of a boolean from const dotenv = require('dotenv')
const variableExpansion = require('dotenv-plugin-varexp')
const myEnv = dotenv.config()
variableExpansion(myEnv) |
I don't know if that would be a good integration point tho. It really still leaves alot that would need to be done to emulate the default behavior of const parseObj = dotenv.config()
for (let key in parseObj) {
... // do stuff
// apply to process.env
} I pushed up an example of working code that emulates that example I have above. orthogonal-var-intergrations branch. What I like is that it add a new option to the Let me know your thoughts @maxbeatty and @motdotla . |
Feels premature to add an integration point with no proposed integrations. I suspect someone will want variable expansion back in the not-so-distance future. The proposed mapping function is good for that, but what happens when someone wants to do more than one thing? Since we're ultimately working with one object ( // jQuery
$('p').find('a').each(...)
// lodash
_.pluck(_.filter(users, 'active', false), 'user'); By exposing dotenv's core competency of a parsed object from a text file, we can allow people to easily continue to alter dotenvValidate(dotenvVarExp(dotenv.config())) |
Any more thoughts on this? All open issues and PRs could be closed as a result of this change. |
The chaining approach is good. Thanks mucho @maxbeatty. Merging. |
Orthogonal Environment Variables
That’s a nice way of saying removing variable expansion. I haven’t been presented with a good use case for variable expansion where copying and pasting (
TEST=$BASIC
) or string concatenation (process.env.TEST_BASIC = process.env.TEST + process.env.BASIC
) wouldn’t be a better solution. By supporting these limited use cases, we're encouraging sub-optimal configuration management and forcing people to escape their variables.process.env
in nodejs docs to make it easier to learn about what we're populatingload
as an alias toconfig
so documentation is more consistentThis would be a breaking change so outlined the changelog as this being a v2 candidate