adonisjs / env

Framework agnostic environment variables parser and validator
https://docs.adonisjs.com/guides/environment-variables
MIT License
37 stars 10 forks source link

feat(env): add support for more than .env.testing alternate environments #14

Closed grplyler closed 4 years ago

grplyler commented 4 years ago

Proposed changes

Following up with my forum post, https://forum.adonisjs.com/t/more-env-files-other-than-env-testing/6562 it seems that adonisjs only supports one alternative .env file called .env.testing. It would seem to me like an easy addition to add support for more .env files based on NODE_ENV environment variable. (I needed 3 for my Adonis and Nuxtjs project)

Types of changes

I have made a small change (less than 5 LOC not including tests) which loads an alternate .env based on NODE_ENV. For example, if NODE_ENV=development, then a .env.development will be loaded and merged. If NODE_ENV=foobar then a .env.foobar will be loaded if it exists, etc. Of course, .env.testing still works as well.

I have also written 3 tests (an additional 6-9ms of testing time) that test my added functionality.

What types of changes does your code introduce?

Checklist

Note: If accepted, I will be happy to add the relevant documentation.

Further comments

While I have 4+ years in Javascript development and 5+ in Python, this is my first formal pull request, and I will not be offended if I need to change anything to improve my addition or if it goes against any principles and gets rejected.

I love Adonisjs and I hope to see it continue to prosper!

Thanks! Ryan

McSneaky commented 4 years ago

Would be cool, if there's one more test :yum:

grplyler commented 4 years ago

I can do that this afternoon! Was actually just reading about japa. Lol another good library from Mr. Virk. Will probably use it in my other projects too.

thetutlage commented 4 years ago

Can you please help the use case in which you need multiple .env files for different environments? I usually work in 3 environments ie. development, staging and production.

I am curious to know the use-case in which you need a separate file for each environment

thetutlage commented 4 years ago

Closing since no response from the issue reporter and not actionable as well