-
Notifications
You must be signed in to change notification settings - Fork 24
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
Question: Possible to load multiple .env files into the shell? #36
Comments
@basickarl can you give me a use case for this? This would require a bit if refactoring to support and I'm not sure how often this would be used. |
One use case would be if your configs are env specific - "qa", "prod", etc. Something like would be useful: env.qa.defaults + .env.qa |
@dmitryvmin It seems that this can already be accomplished with the e.g. for QA: Then for prod: Am I misunderstanding? |
I was about to post this same feature request. The idea would be to allow for multiple layers of defaults/settings, as provided by These other modules, however, aren't easily made compatible with Implementing this feature a really simple change as well. The vast majority of the change is simply updating let envFiles = [];
[ options.defaults, options.path ].forEach(files => {
if (!files || files.length === 0) return;
if (!Array.isArray(files)) files = [ files ];
envFiles.push(...files);
});
let configData = files.reduce((accumulator, file) => {
let fileData = loadEnvironmentFile(file, options.encoding, options.silent);
return { ...accumulator, ...fileData };
}); Beyond that, pretty much only CLI argument parsing would need to be tweaked, and documentation would need to be updated. |
@goatandsheep You perhaps need to update the tests? |
@goatandsheep , it looks like you copied my code verbatim (and my code still makes sense to me, surprisingly), so I'm going to guess 'yes', but I honestly barely remember this request, hah. |
Question: Is it possible to load multiple .env files into the shell?
npx dotenv-extended --path=first.env dotenv-extended --path=second.env node herro.js
Or something like:
npx dotenv-extended --path=first.env,second.env node herro.js
The text was updated successfully, but these errors were encountered: